Search code examples
iosobjective-cuitableviewreloaddata

No visible interface for UITableViewController declares the selector ReloadData


I have a UITableViewController as my primary ViewController in an app. My goal is to override the reloadData method.

Both the delegate and datasource of the tableview were set in the Storyboard automatically:enter image description here

However, when I call the super method of the class in the override, I get the error seen in the title of this question.

my code is very very simple:

- (void)reloadData {
    [super reloadData];
}

Furthermore, when I call reloadData without the override in other parts of my app, it does not seem to trigger cellForRowAtIndexPath:

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
    if ([elementName isEqualToString:@"theThingImLookingFor"]) {
        [self.tableView reloadData]; //no error thrown, but no tableReloading either
    }
}

How do I get this to work? I feel like I'm missing something obvious here...


Solution

  • UITableViewController does not define a reloadData method. That's a UITableView method. If you've defined one, it won't get called unless you call it yourself. I suggest putting a breakpoint on your reloadData method and seeing from where it's being called.

    If you yourself call your reloadData method it won't do anything. You need to call your tableView's reloadData method.

    You could certainly implement a reloadData method in your UITableViewController that in turn calls the table view's reloadData method:

    - (void)reloadData {
        [tableView reloadData];
    }