从根据索引排序的核心数据中获取数据
在核心数据实体中,我有一个索引为 (1,2,3,4,5,6,7,......) 的字段索引
我想根据该索引从核心数据中获取数据,但我做不到
我无法正确设置排序描述符
任何人请帮助一些代码片段
最佳答案
告诉获取请求对您的数据进行排序...
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"myEntity"];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"index" ascending:YES];
fetchRequest.sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
现在你fetch的时候,数据会按照索引字段排序。
关于iPhone:从根据索引排序的核心数据中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11435835/