开发者

Error when deleting from an NSFetchedResultsController controlled UITableView outside of the table view

I'm trying to remove an object managed by an NSFetchedResultsController in a UITableView - and I'm attempting to do so from a separate view via add/remove buttons. However, it seems as though controller and table are getting out of whack as I switch between views and I can't quit figure out 开发者_开发知识库why. Here is the error I am getting - unfortunately it doesn't always happen depending upon what path I take through the application:

Serious application error. Exception was caught during Core Data change processing: *** -[NSCFArray removeObjectAtIndex:]: index (6) beyond bounds (6) with userInfo (null)

I can see my delegate methods getting called correctly and the delete code is very straightforward and I don't see any errors there.

Any thoughts/debugging hints would be much appreciated.


I encountered a similar problem. The only solution I found so far is to re-fetched the NSFetchedResultsController:

if (![[self resultsController] performFetch:&error]) {
   NSLog(@"%@:%s Error refreshing the fetch controller %@", [self class], _cmd, 
      [error localizedDescription]);
   NSAssert(NO, @"Failed to refresh the fetch controller");
}


I'm not sure if we had the same issue, but my issue was solved with the following:

(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return self.fetchedResultsController.sections.count;}

(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [self.fetchedResultsController sections][section];
return [sectionInfo numberOfObjects];}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜