I have a UITableView which I am trying to set up. The sections should have titles and each section will have a different number of rows.
If I hardwire the return data in, then it works, however if I try and pull the data from NSMutableArrays in the relevant methods then the app crashes with no explanation in the console.
To summarise
works (giving me 5 rows per section)
but
doesn't
the code (placed in viewDidLoad)
outputs
sectionNumRows[]=1
sectionNumRows[]=4
as i would expect.
What am I doing wrong in the numberOfRowsInSection method?
This behaviour is repeated in the titleForHeaderInSection method. i.e. if I hardwire the return string
return @"testing";
then the app works (with two section titles of 'testing')
but if I try accessing the names from an NSMutableArray
return [sectionTitles objectAtIndex
int)section];
then, again, it falls over with no explanation in the console.
If I hardwire the return data in, then it works, however if I try and pull the data from NSMutableArrays in the relevant methods then the app crashes with no explanation in the console.
To summarise
Code:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
//return [[sectionNumberRows objectAtIndex:section] intValue];
return 5;
}
but
Code:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [[sectionNumberRows objectAtIndex:section] intValue];
//return 5;
}
the code (placed in viewDidLoad)
Code:
for (int i = 0; i < [sectionNumberRows count]; i++) {
NSLog(@"sectionNumRows[]=%d", [[sectionNumberRows objectAtIndex:i] intValue]);
}
sectionNumRows[]=1
sectionNumRows[]=4
as i would expect.
What am I doing wrong in the numberOfRowsInSection method?
This behaviour is repeated in the titleForHeaderInSection method. i.e. if I hardwire the return string
return @"testing";
then the app works (with two section titles of 'testing')
but if I try accessing the names from an NSMutableArray
return [sectionTitles objectAtIndex
then, again, it falls over with no explanation in the console.