3

how do you overload the UITableView "reloadData" method in a UITableViewController?

e.g. to put a log statement to see/confirm when reloadData is being called on each of my UITableViews

Greg
  • 34,042
  • 79
  • 253
  • 454

1 Answers1

8

Just subclass the UITableView and override reloadData function:

Header

@interface MyUITableView : UITableView

Function

- (void)reloadData {
    [super reloadData];
    NSLog("Hello");
}

To use it you make instantiate MyUITableView instead of UITableView

Andreas
  • 2,450
  • 1
  • 18
  • 20
  • This is the best way to do this. – sosborn Oct 18 '11 at 06:11
  • so no why to achieve without subclassing? also I was asking about is there a way to override within in my UITableViewController...so is the answer I have to create a custom subclass for UITableView, and then in my UITableViewController XIB make sure it's internal view points to my MyUITableView as opposed to UITableView? – Greg Oct 18 '11 at 06:30
  • 1
    Yes, you must change the class of the UITableView in interface builder if you use it. – Andreas Oct 18 '11 at 06:39