NSFetchedResultsController:排序描述符和节
我有一个像这样的核心数据模型...
[Country] <--->> [League] <--->> [Match]
  我正在使用NSFetchedResultsController将Matches显示到UITableView 。 
我之前做过这一百万次,但由于某些原因,这些部分出错了,我不知道为什么。
我已经创建了类似描述符...
NSSortDescriptor *countrySD = [NSSortDescriptor sortDescriptorWithKey:@"league.country.name" ascending:YES];
    NSSortDescriptor *leagueSD = [NSSortDescriptor sortDescriptorWithKey:@"league.name" ascending:YES];
    NSSortDescriptor *dateSD = [NSSortDescriptor sortDescriptorWithKey:@"startDate" ascending:YES];
    request.sortDescriptors = @[countrySD, leagueSD, dateSD];
  首先,我想检查一下我是否按照正确的顺序进行了这些操作。  这应该league.name country.name排序,然后按照league.name排序,然后按startDate排序。 
即
Albania事情都应该在Spain之前发生。 League 1任何事情都应该在League 2之前。 startDate顺序显示,并且以最早的顺序显示。   然后我用这个创建NSFRC ... 
_fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:self.moc sectionNameKeyPath:@"league.leagueID" cacheName:nil];
  所以这应该按照不同的league.leagueID值进行匹配。 
它应该是像...
Albania - League 1
    12:00
    13:00
Albania - League 2
    09:00
    14:00
France - League 1
    09:00
Spain - A League
    08:00
    12:00
Spain - B League
    09:00
它虽然没有工作。 我为同一联盟获得了多个标题。 一些比赛出现在错误的标题下等...
  我检查了出现在错误联赛下的比赛数值(NSLogged),他们实际上拥有正确的联赛。  所以即使他们有Spain - A League他们出现在France - League A (例如)下。 
任何想法如何我可以解决这个问题?
  用作sectionNameKeyPath参数的键路径必须与第一个排序描述符中使用的键相同(或者生成相同的相对排序)。 
有(据我所知)没有办法使用两个或多个排序描述符来将抓取的结果控制器的结果分组到分段中。
链接地址: http://www.djcxy.com/p/6141.html上一篇: NSFetchedResultsController: sort descriptors and sections
