开发者

Using UISegmentedControl to switch NSFetchedResultsController

In my view I have a table view along with a segmented control. The table view is getting its data from an NSFetche开发者_StackOverflow社区dResultsController.

When clicking the segmented control I try to change to another NSFetchedResultsController (which is using another predicate, sort descriptor and even another type of entity).

Something like suggested in one of the answers to this question.

I also have typedefed my own enum, to keep track of which state the table view is in (which segment that currently is selected).

The problem is, when the table view reloads its data, I get an "NSInternalInconsistencyException", since the number of sections and/or the number of rows have changed from X to Y - but "(0 inserted, 0 deleted)".

My questions are:

  • Is it even possible to solve this the way I'm trying to?
  • Where should the beginUpdates, endUpdates and reloadData go (in relation to the switch of NSFetchedResultsController)?
  • Anyone with better solutions to this problem?

Thanks in advance!


If you are doing lazy loading of the FRC, then kill the FRC and call reloadData on the UITableView to get the new FRC with the new predicates/sort descriptors to be used.

This is the same thing you do when using a UISearchBar, as answered in this question

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜