Search code examples
objective-cuitableviewobjective-c-category

Accessing a view controller's delegate from a Category on that view controller


I've created a Category on UITableViewController and was wondering if it's possible to access the tableViewController's delegate, i.e. can I put something like this into my Category?

UIView *firstHeader = [self.delegate tableView:self.tableView viewForHeaderInSection:0];

Obviously, the above doesn't work, but is there something along those lines I can use?


Solution

  • The delegate is on the tableView, not the tableViewController, hence the following is what's needed:

    UIView *firstHeader = [self.tableView.delegate tableView:self.tableView viewForHeaderInSection:0];