After I add a Table View to a View Controller, I control-drag twice from the TV to the VC in Interface Builder to specify that the VC is the datasource and delegate of the Table View.
In the View Controller I then have to specify the same in the class definition or View Controller extension.
Why is this? Isn't this redundant?
Thanks.
Not at all. What you are doing is two different things.
In the
extension
you are telling the compiler "this class conforms to theUITableViewDatasource
andUITableViewDelegate
protocols and so can be used as such for aUITableView
".In Interface Builder you are telling the
UITableView
"this class here is what I want you to use as yourdatasource
anddelegate
".