CodeGrue is right. After several days thinking why [subclassOjb.tableView reloadData] does not work, I gave up trying to understand this and decided to use only two methods that I know, and it is very easy to implement: 1- Notification Center (from tableviewcell you should not use this one) 2- or use a supervisor to get a handle to your tableview property (this is ideal for uitableviewcells).
Please note that using the supervisor method will only work on your uitableviewcell class, most likely, if you have a custom cell, you will have a uitableviewcell class, the supervision of which will be your table controller or any other class that you have with the uitview + delegate datasource.
Now, if you need to reload the table view from another class, let the datasource class say singleton or something else; you must use a block in the tableview class to load data in another thread with an internal block to reload the table on mainthread.
If you are at a different level and something happens, you need to reload the table in your table view. Well, at this moment your table is not on the screen, there is no reason why you should reload the table if no one sees it. Just add [self.tableview reloadDAta] to your viewWillAppear method, when users return to the viewviewcontroller, it will reload the table on the fly.
In any case, for tableviewcell, just use the following inside your action to reload Data (credit for CodeGrue)
UITableView *parentTable = (UITableView *)self.superview; [parentTable reloadData];
** Another topic, but for those of you who are starting now. This will save you from possible headaches - after creating your tableclass and before you even begin to deal with its delegation methods - do the following: in your DidLoad view, add the following code:
self.tableView.delegate = self; self.tableView.dataSource = self;
Marcio arantes
source share