开发者

Getting sectionNameKeyPath to work with CoreData/UITableViewController

  1. In my AppDelegate I create an NSFetchedResultsController with sectionNameKeyPath set to @"group".
  2. In viewWillAppear in my TableViewController I performFetch, then call a method called findGroups.
  3. findGroups does some complicated analysis of the entire dataset to identify groups, then sets the "group" transient property on each object to the correct string value. I can see with NSLog that these are all set correctly and in coherent groups.

But, tinker as I may, my cells are shown in a singl开发者_如何学JAVAe section with the title of the first group. Any ideas?


Have you implemented:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [[fetchedResultsController sections] count];
}

You also have the problem that the sectionNameKeyPath can't be a transient value.


Actually, this worked fine for me by adding a step 4: [self.tableView reloadData];

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜