Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何使用NSFetchedRequest或NSPreditate从实体中选择所有行?_Iphone_Core Data_Select_Nspredicate_Nsfetchrequest - Fatal编程技术网

Iphone 如何使用NSFetchedRequest或NSPreditate从实体中选择所有行?

Iphone 如何使用NSFetchedRequest或NSPreditate从实体中选择所有行?,iphone,core-data,select,nspredicate,nsfetchrequest,Iphone,Core Data,Select,Nspredicate,Nsfetchrequest,我对核心数据非常陌生,但我仍然对它和它的所有可能性感到困惑 我的模型中有一个表用户,我希望以“SELECT*FROM USER”的形式获取所有行 实现这一目标的最佳方式是什么 非常感谢您的帮助。来自NSFetchRequest文档: 如果未指定谓词,则会选择指定实体的所有实例(根据其他约束,请参阅executeFetchRequest:error:了解完整详细信息) 基本的提取操作如下所示: NSEntityDescription *entity = [NSEntityDescription e

我对核心数据非常陌生,但我仍然对它和它的所有可能性感到困惑

我的模型中有一个表用户,我希望以“SELECT*FROM USER”的形式获取所有行

实现这一目标的最佳方式是什么


非常感谢您的帮助。

来自
NSFetchRequest
文档:

如果未指定谓词,则会选择指定实体的所有实例(根据其他约束,请参阅executeFetchRequest:error:了解完整详细信息)


基本的提取操作如下所示:

NSEntityDescription *entity = [NSEntityDescription entityForName:theEntityName inManagedObjectContext:_context];

NSFetchRequest *request = [NSFetchRequest new];
[request setEntity:entity];
在此阶段,您可以使用NSSortDescriptor应用排序

然后获取所有实体:

NSError *error;    
NSMutableArray *fetchResults = [[_context executeFetchRequest:request error:&error] mutableCopy];

使用[NSPredicate predicateWithValue:YES]选择全部。

在fetchResults中,实体对象将是实体对象,不是吗?正确!它们是正确类型的实体。