If I have a UIViewController and I hook up a tableView to it in storyboards, connect the tableview outlet, and then connect the datasource and delegate methods via the connections inspector (cntrl+drag to vc orange circle icon), do I still need to add self.tableView.delegate = self
and self.tableView.datasource = self
to the actual view controller? Of course in the actual vc I'm implementing the tableView data/delegate protocols.
Also I'm assuming whatever the answer is the same would go for a collection view controller being connected via storyboard the same way?
What are the pros and cons of adding it?
class FooController:UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.datasource = self
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { ... }
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { ... }
}