I’ve spent literally weeks trying to get sections and rows to work in my table and have finally did it!
Next I noticed that even though I had plenty of data to view, I could not scroll down past what is first displayed on screen. Additionally, the scroll bar seems to be fatter than usual and there is a number 2 displayed in the upper right hand corner.
Not sure what I’m doing wrong. Can someone lead me nudge me in the right direction?
I couldn’t capture the fat scroll bar, but it is definitely wider than it should be.
- (void)setupFetchedResultsController {
NSString *entityName = @"Regster";
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:entityName];
request.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"addDate" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)]];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Regster" inManagedObjectContext:self.managedObjectContext];
[request setEntity:entity];
[request setResultType:NSDictionaryResultType];
[request setReturnsDistinctResults:YES];
//[request setFetchBatchSize:2];
self.fetchedResultsController.delegate = nil;
[request setPropertiesToFetch:[NSArray arrayWithObjects:@"addDate", @"regType", nil]];
NSString *query = self.selectedAccounts.name;
request.predicate = [NSPredicate predicateWithFormat:@"inAccounts.name CONTAINS[cd] %@", query];
self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:self.managedObjectContext sectionNameKeyPath:@"addDate" cacheName:nil];
[self performFetch];
NSError *error = nil;
NSUInteger count = [_managedObjectContext countForFetchRequest:request error:&error];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self setupFetchedResultsController];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [[self.fetchedResultsController sections] count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
id sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section];
return [sectionInfo numberOfObjects];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section];
return [sectionInfo name];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Account Register";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
}
[self.tableView setScrollEnabled:YES];
NSDictionary *regtype = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.textLabel.text = [regtype objectForKey:@"regType"];
return cell;
}

EDIT1: Changing @”addDate” of the sectionNameKeyPath of the fetchedResultsController, results in the removing of the dates and sections, leaving one section and the scroll works fine. Leaving the @”addDate” does what I want with sections, but I don’t understand why it doesn’t scroll with that 2 and a “fat” scroll.
EDIT2: I found my problem… I had borrowed code from another instructional course to get my CoreDataTableViewController working and it had implemented sectionIndexTitlesForTableView. Commented out and is working!
I found my problem… I had borrowed code from another instructional course to get my CoreDataTableViewController working and it had implemented sectionIndexTitlesForTableView. Did some massive searching and found this brought up somewhere. Commented out the sectionIndexTitlesForTableView method and it is working perfectly!