我设置了一个获取请求来检索“用户”项目的某些属性:
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:entity];
[fetchRequest setResultType:NSDictionaryResultType];
[fetchRequest setPropertiesToFetch:[NSArray arrayWithObjects:companyName, firstName, lastName, completeItems, incompleteItems, objectID, nil]];
[fetchRequest setPredicate:predicate];
[fetchRequest setSortDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:SortOptionCompany ascending:YES],
[NSSortDescriptor sortDescriptorWithKey:SortOptionFirstName ascending:YES]]];
[fetchRequest setFetchBatchSize:kBatchSize];
我初始化我的NSFetchedResultsController:
NSFetchedResultsController *frc = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
managedObjectContext:self.context
sectionNameKeyPath:@"sectionIdentifier"
cacheName:nil];
属性“sectionIdentifier”是User实体的瞬态属性。但是,当我执行此操作时,我收到消息:
"returned nil value for section name key path 'sectionIdentifier'. Object will be placed in unnamed section"
获取的信息未按要求分组。这是因为我需要为keyPath获取整个NSManagedObjects不是nil,还是有办法在检索字典时使用sectionKeyPath?我也尝试过使用setPropertiesToGroupBy:没有成功。
答案 0 :(得分:0)
由于我没有找到解决此问题的解决方案,因此我在检索后不使用sectionKeyPath并手动将数据分类到各个部分。