It’s so wierd:
_tableDataSectionTitles is a property of this UITableViewController subclass & an NSArray.
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
NSLog(@"%@", _tableDataSectionTitles); // returns: ( "string" )
NSLog(@"%@", [_tableDataSectionTitles objectAtIndex:0]); // returns: "string"
NSLog(@"%i", section); // returns 0
NSLog(@"%@", [_tableDataSectionTitles objectAtIndex:section]; // returns "string"
return [_tableDataSectionTitles objectAtIndex:section]; // returns: *** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array
what’s with that!? (everything else is working properly. I checked. Thrice.) (seriously though, this is like the first thing that it runs through, so nothing should be wrong here)
I’ve also tried it with out even using the array:
NSString *rep = [[NSString alloc] init];
if (section == 0) {
rep = @"Stuff";
} else { // doesn't even need it - it won't run through it anyway
//rep = [_tableDataSectionTitles objectAtIndex:section]; // commented out just to not have any doubts
}
return rep;
but still the same error. help!
Well, I’ve got it.
So, turns out that my _tableDataSectionContents array was empty while the _tableDataSectionTitles had one in it. so, I still don’t understand why exactly it raised the error for a completely separate array, but it works now! thanks for all your help.