How many times should the tableView:numberOfRowsInSection
method be called when populating a table view?
My application is crashing with no warnings, errors, or a stack trace. I have also tested for memory leaks and have found none. The app holds steady at about 1.4MB.
I have NSLog reporting as methods are messaged, and I notice that tableView:numberOfRowsInSection
is being called multiple times. The app crashes during one of these "extra" calls. The point at which the app crashes varies. I should point out that the table is populating about 600 cells, if that makes a difference.
I can post code if you want, but my data source comes from a singleton class
, so It is a lot of code. Any help would be greatly appreciated.
See my answer in another similar question: link
Basically, calls to the the delegate methods of a table view can be triggered by different events. It wouldn't be a suprise to me that UITableView calls numberOfRowsInSection
multiple times (even for the same section).
I faced the same problem, the first time tableview instance is not nil and the subsequent times it is nil. The problem was, I had yet not set the return value for
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
and because of this it kept happening. Once I set a return value the problem was gone. Hope this helps someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With