objective-c - 在 NSFetchRequest 中按实体名称排序

标签 objective-c ios core-data nsfetchedresultscontroller nsfetchrequest

我有一个抓取结果 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/

相关文章:

objective-c - Objective-C 中删除字符串中的字符

ios - "Core Data is not a relational database."为什么知道这一点很重要?

ios - 仅在 iOS 8 中将子 UIViewController 锁定为纵向

ios - Core Data Stack 应该从 NSObject 继承吗?为什么?

ios - 如何过滤在 Core Data 中有对象的 TableView ?

swift - 是否可以将整个 CoreData-Stack 放在一个框架中?

iPhone:UIWebView打开外部浏览器后,返回app再次打开

objective-c - 如何以编程方式打开 NSComboBox 的列表?

c++ - iOS,objective-c 代码中的 shared_ptr 生命周期?

ios - 将 UILabel 添加到 UITextView