I am absolutely bewitched by this and cannot understand what I am missing. Perhaps there is still much to learn about basic data.
This is my setpoint controller that displays a table without partitions, but my display controller works:
self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:self.buckyballDatabase.managedObjectContext sectionNameKeyPath:nil cacheName:nil];
TAKING ATTENTION as soon as I applied sectionNameKeyPath to add sections. Sections are added, but my search display controller is broken, causing an error below:
*** Assertion failure in -[UITableViewRowData rectForRow:inSection:], /SourceCache/UIKit_Sim/UIKit-2372/UITableViewRowData.m:1630 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for rect at invalid index path (<NSIndexPath 0x7481040> 2 indexes [0, 1])'
And here are my implementations of the data view in the table view . If filterList is NSArray: -
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { if (tableView == self.tableView) { return [[self.fetchedResultsController sections] count]; } else { return 1; } } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (tableView == self.tableView) { return [[[self.fetchedResultsController sections] objectAtIndex:section] numberOfObjects]; } else { return [self.filteredList count]; } } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if (tableView == self.tableView) { return [[[self.fetchedResultsController sections] objectAtIndex:section] name]; } else { return nil; } } - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index { if (tableView == self.tableView) { if (index > 0) { return [self.fetchedResultsController sectionForSectionIndexTitle:title atIndex:index-1]; } else { self.tableView.contentOffset = CGPointZero; return NSNotFound; } } else { return 0; } } - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { if (tableView == self.tableView) { NSMutableArray *index = [NSMutableArray arrayWithObject:UITableViewIndexSearch]; NSArray *initials = [self.fetchedResultsController sectionIndexTitles]; [index addObjectsFromArray:initials]; return index; } else { return nil; } }
An exception is thrown in cellForRowAtIndexPath in the line below: -
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
Please ask if additional information is required. I scratch my head so much over it.
Bilal wahla
source share