tableView reloadData not working
It looks like you are never setting the delegate
and datasource
properties on your tableview, no? You're implementing the methods in those protocols inside tableview.m
but not setting the two properties to self
hence calling reloadData
having no effect.
Does this help?
Edit:
Looks like you have a tableView
property set on a subclass of UITableView
and hooked up to an interface builder file. This is an odd setup (a tableview within a tableview). Usually you would have something like a UIViewController
subclass hooked up to an XIB and set an
@property (nonatomic, strong) IBOutlet UITableView * tableView
in that subclass, or something similar. And then handle the data fetching and tableview delegate/datasource inside that viewcontroller subclass.
But here, because of the nested UITableView
s it's not as straightforward. Is there a reason for this design? I recommend moving to something like I describe above to help bring clarity to the setup.
Also, try adding some NSLog
statements into your init
method to see if the tableview != nil and the delegate and datasource properties have been set. My suspicion is that the connection is not being made.
Also, unrelated to the problem at hand, you no longer have to manually @synthesize ivar = _ivar
, it will be done for you automatically using the underscore convention.
I was having the same issue, that the reload was not working. I believe the delegate method I was calling it from was in a background thread which was causing the problem. My solution was to create a new method (below) and call the reload from there instead, while also ensuring to call it from the main thread:
- (void) tocLoad {
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
}