0

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.

1 Answer 1

4

[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];
  }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.