fetch请求问题
在核心数据中,我使用 fetchRequest 和谓词进行搜索,如下所示
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"Study"
inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:
@"( StudyID == %@ )",self.StudyID]];
NSArray * StudyList = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
如何检查是否有返回值
in core data , I search using fetchRequest and predicate like the following
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"Study"
inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:
@"( StudyID == %@ )",self.StudyID]];
NSArray * StudyList = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
how to check if there a return values or not
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
做一些类似的事情:
希望有帮助。
Do something like:
Hope that helps.
您可以像这样检查
StudyList
数组的大小:顺便说一句,您应该遵循命名约定。像
StudyList
这样的变量应该以小写字母开头,即studyList
。按照惯例,以大写字母开头的名称表示某种常量,例如类、实体、常量等。You check the size of the
StudyList
array like so:As an aside, you should follow the naming conventions. A variable like
StudyList
should be written starting with lower case i.e.studyList
. By convention, names that start with capital letters indicate some sort of constant e.g. classes, entities, constants etc.只需阅读该方法的文档:
Just read the documentation of the method: