我有一个实体头,它有一个属性 NSDictionary ,它在模型中被声明为可转换的。现在我不想对 fetchedRequestController 中的标头数组进行排序。并且传递 nil 或 null 对象会产生错误。请帮助其紧急。
让我从上次重新开始:如果我有一个实体,它具有可转换的属性标题。我在生成的类中将 id 类型更改为 NSDictionary。我现在需要以 entity.attribute name.key 的形式访问字典的键...我收到一个错误,因为此类不是键的键值编码投诉:(键)...解决此问题的方法是什么。
// Create and configure a fetch request with the Book entity.
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"headers" inManagedObjectContext:self.tableCellGenericMoc];
[fetchRequest setEntity:entity];
// Create the sort descriptors array.
NSSortDescriptor *headersDescriptor = [[NSSortDescriptor alloc] initWithKey:@"headersDictionary" ascending:NO];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:headersDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
// Create and initialize the fetch results controller.
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.tableCellGenericMoc sectionNameKeyPath:@"headresDictionary" cacheName:@"Root"];
self.fetchedResultsController = aFetchedResultsController;
fetchedResultsController.delegate = self;
上面的选择器给出了一个错误,因为它不能对 headersDictionary 进行排序......