Your first two methods look wrong (in particular the numberOfRowsInSection
method).
You should use the "standard implementation"
- (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];
}
The error occurs because self.cart.count
(whatever that is) does not reflect the
correct number of objects after an items has been inserted.