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

34 views Asked by At

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?

1

There are 1 answers

0
bcl On BEST ANSWER

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];