我有一个抓取结果 Controller ,它应该显示具有多个子实体的特定实体的所有项目。
fetched results controller 中的部分应该基于实体名称,即一个项目属于哪个子实体。将 sectionNameKeyPath
设置为 @"entity.name"
有效。
然而,似乎不可能为提取请求获得正确的排序描述符。像 [NSSortDescriptor sortDescriptorWithKey:@"entity.name"ascending:YES]
这样的事情会导致像 keypath entity.name not found in entity Something
这样的错误。
最佳答案
尝试使用 [NSSortDescriptor sortDescriptorWithKey:@"name"ascending:YES];
您不需要前面的实体,因为实体已经由获取请求定义。另见 Sort Descriptor Class Reference .
关于objective-c - 在 NSFetchRequest 中按实体名称排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6431093/