I'm setting up the way texLabel
of a UITableViewCell
is determined in cellForRowAtIndexPath
, and the problem is that when pulling from agendaTableArray
, it repeats the item in every section of the table, rather than only in the section it belongs to. In other words, I want each item in the array to be a row in its own section.
Here's how it currently looks:
Here's how I'm setting up cellForRowAtIndexPath
:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyReuseIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:MyIdentifier];
cell.textLabel.text = nil;
}
self.agendaTableArray = @[@"Dinner with Rebekah", @"Soccer game", @"Denist appt.", @"Celebrate job offer, drinks with Pierre!", @"No events today!"];
// Set title of the event
if (self.datePicked == [NSNumber numberWithInt:16]) {
NSLog(@"cellForRowAtIndexPath says self.datePicked is 16");
}
else if (self.datePicked == [NSNumber numberWithInt:17]) {
NSLog(@"cellForRowAtIndexPath says self.datePicked is 17");
}
else if (self.datePicked == [NSNumber numberWithInt:18]) {
NSLog(@"cellForRowAtIndexPath says self.datePicked is 18");
}
else if (self.datePicked == [NSNumber numberWithInt:19]) {
NSLog(@"cellForRowAtIndexPath says self.datePicked is 19");
}
else {
}
cell.textLabel.text = self.agendaTableArray[indexPath.row];
cell.textLabel.font = [UIFont systemFontOfSize:14];
[self whatSectionsAreVisible];
return cell;
}
How can I set it to only load the item from agendaTableArray
in the first section's cell?