2.13. 获取托管对象(Core Data 应用程序实践指南)
用NSFetchRequest获取NSArray,里面都是托管对象。如果上下文里没有数据,就会从持久化存储区里获取。
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Item"]; NSArray *itemObjects = [_coreDataHelper.context executeFetchRequest:request error:nil]; for (Item *item in itemObjects) { NSLog(@"item name = %@", item.name); }
2.13.1. 排序
2.13.2. 筛选
2.13.3. 获取请求模板