Update view controller

In my application deletion, I have this method that is automatically turned off to do something when the view controller is selected.

If the viewController type is SavedViewController, then this is a subclass of UITableView, and I would like to update the table. However, this code does not work:

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
  if([viewController isKindOfClass: [SavedViewController class]]) {
    [viewController.tableView reloadData];
  }
}

The error I get is "the query for tableView is not a structure or union. In the SavedViewController class, I can do this just fine:

[self.tableView reloadData];

So what am I doing wrong in my function?

+3
source share
2 answers

Toggle this line:

[viewController.tableView reloadData];

For this:

[[(SavedViewController *)viewController tableView] reloadData];
+2
source

try casting on uitableviewcontroller

0

Source: https://habr.com/ru/post/1712813/


All Articles