views:

288

answers:

1

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.

Cheers, Matt

A: 

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");
}
Patrice