I’m calling the numberOfRowsInSection method of the UITableView delegate inside of the heightForRowAtIndexPath but it gives me a Bad Access Error:
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
...
NSLog(@"number of rows in section: %i", [tableView numberOfRowsInSection:[indexPath section]]);
...
}
Can anybody tell me whats wrong here?
You need to return an actual value here. So instead of calling
[tableView numberOfRowsInSection:[indexPath section]]simply do the same thing again.In order not to duplicate your code you could create a helper method which you can call in both places, namely, your
heightForRowAtIndexPathmethod and thenumberOfRowsInSectionmethod: