我遇到了一些来自NSFetchedResults控制器的混合,索引,可搜索结果集的问题.我将它设置为存储实体的索引AZ第一个首字母,然后希望它显示数字的第一个首字母(即,如UILocalizedIndexCollation所做的那样).
我已经编写了将Artist对象的"firstInitial"属性保存为NSString @"#"的代码,如果全名以数字开头,我似乎已经在我的UITableViewController中使用自定义排序描述符完成了一半的代码.问题是它只有在我退出/重新启动应用程序之后才能运行.
此时,获取结果中的#部分显示在顶部.它将一直保持在那里,直到我强制数据更改(添加/删除托管对象),然后搜索条目,并清除搜索(使用searchDisplayController).此时,部分重新排序将启动,#部分将移至底部...
我显然缺少某些东西/长时间盯着相同的代码.或者,有一种更简单的方法,我不知道/无法在谷歌上找到它!
任何帮助,将不胜感激!
谢谢
肖恩
我的UITableViewController的相关代码如下.
- (void)viewDidLoad
{
// ----------------------------------
// Various other view set up things in here....
// ...
// ...
// ----------------------------------
NSError *error;
if (![[self artistResultsController] performFetch:&error]) {
// Update to handle the error appropriately.
NSLog(@"Failed to fetch artists: %@, %@", error, [error userInfo]);
exit(-1); // Fail
}
}
- (NSFetchedResultsController *)artistResultsController {
if (_artistResultsController != nil) {
return _artistResultsController;
}
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"Artist" …Run Code Online (Sandbox Code Playgroud) iphone core-data objective-c uitableview nsfetchedresultscontroller