Reputation: 541
I have a property called currentViewController that either points to a UIViewController or UITableViewController depending on what segment in a UISegmentedControl is active.
If the currentViewController happens to point to UITableViewController, I can change the UITableView into editing mode by
[self.currentViewController setEditing:YES animated:YES];
However, I now want to run reloadData on the tableView. I tried this,
[self.currentViewController reloadData];
and it failed.
Any ideas on how can I reloadData on the tableView.
Upvotes: 0
Views: 50
Reputation: 414
[self.currentViewController setEditing:YES animated:YES];
Works well because it's defined for both UIViewController (link) and UITableViewController (via subclassing UIViewController). You really want to be calling reloadData
on the tableView, not on either of the ViewControllers.
Try something like:
if([self.currentViewController isKindOfClass:[UITableViewController class]]){
UITableViewController *tableVC = (UITableViewController *)self.currentViewController;
[tableVC.tableView reloadData];
}
Upvotes: 4