我有一个fetchedResultsController需要获取NSMutable数组listOfInstructions中所述的指令。这很好用。
但是,我希望获取的排序顺序与listOfInstructions中的指令顺序相同。我如何为此更改sortDescriptor? 我看了选择器和比较器,找不到简单的解决方案。
// Define a predicate to get only specific list from DB
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"instructions IN %@",listOfInstructions];
[fetchRequest setPredicate:predicate];
// Edit the sort key as appropriate.
NSSortDescriptor *sortDescriptor = [
[NSSortDescriptor alloc]
initWithKey:@"instructions"
ascending:YES
];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
答案 0 :(得分:1)
如果您正在寻找实施自定义排序,请在Core Data Table View Section Sort by weekdays using NSSortDescriptor
检查gerry3基于类别的解决方案