I am using core data to fetch an entity. I only want those results to show up in the second section of my tableview and something else show up in another section... But I am getting the crash. What am I doing wrong?
index 1 beyond bounds [0 .. 0]
Here is some code
index 1 beyond bounds [0 .. 0]
Here is some code
Code:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
switch(section){
case 0:
return 7;
case 1:
return [[[self.fetchedResultsController sections] objectAtIndex:section] numberOfObjects];
}
return 0;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
Player *p = [_fetchedResultsController objectAtIndexPath: indexPath];
switch (indexPath.section) {
case 0:
switch (indexPath.row) {
case 0:
cell.textLabel.text = _team.teamName;
break;
case 1:
cell.textLabel.text = _team.headCoach;
break;
default:
break;
}
break;
case 1:{
cell.textLabel.text = p.firstName;
cell.detailTextLabel.text = p.team.teamName;
}
default:
break;
}