I am following the BigNerdRanch iOS Programming book and I am on this one chapter that deals with UITableViewController. I have been wondering however where UITableViewController finds out about its delegate and dataSource. Currently I have it as
@interface ItemsViewController : UITableViewController <UITableViewDataSource, UITableViewDelegate>
But there is nothing that looks like:
[self.tableView setDelegate:self]
I am just wondering how the UITableViewController finds out about its delegate and dataSource
If you were setting up the
UITableViewyourself, you would have to point it to a delegate and data source.UITableViewControllersets up theUITableViewand sets the delegate and dataSource properties to itself. When you subclassUITableViewController, you get this behavior for free.Your question is flawed because
UITableViewControllerdoesn’t have a dataSource and delegate, theUITableViewit is controlling does. And theUITableViewControlleris the dataSource and delegate because it sets things up that way.