IOS 5 核心数据按字符串属性排序不起作用



我有一个属性imageName,即 String 并设置为索引

我正在尝试 sort 我的获取结果 this imageName

它仅在我第一次输入使此获取的ViewController时起作用。下次似乎是任意对结果进行排序的(即使从Uinavigation Controller中弹出并重新创建)。

字符串的形式是:hair001.pnghair002.pnghair003.png,...

这是我执行获取的方式:

NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"AvProperty"];
request.predicate = [NSPredicate predicateWithFormat:@"type = %d && isPrototype=%@",type,[NSNumber numberWithBool:YES]];
request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"imageName" ascending:YES]]; 
NSError *error;
NSArray *properties = [self.context executeFetchRequest:request error:&error];

有什么建议吗?

确保您的视图控制器重新出现时会适当更新。在viewWillAppear中,您可以向获取的结果控制器发送performFetch:消息以刷新您的表观视图。

最新更新