I think I fully understand the concept of delegation, my question is that when we do:
class someViewController : UIViewController, UITableViewDelega
would it ever be possible that we wouldn't want to set tableView.delegate to self?
What's tableView.delegate
? Your class someViewController
is not a subclass of UITableViewController
(and does not have a tableView
property). It does not even know that you handle a table view.
The fact that your type declaration conforms to UITableViewDelegate
does not make it obvious on which actual table view instance it should be set.
If there is a chance that tableView.delegate is set to something other than self...well what is that?
Often times it's wise to split up functionality into multiple types to reduce the complexity of the view controller. Your someViewController
might have a viewModel
property that handles all thing regarding the table view.