I cannot understand why the methods assigned to the delegate property of a class couldn't be implemented firstly on that class
IMO it would be easier to understand the code and the logic behind it but maybe I'm missing something
f.e.
class ViewController : UIViewController, UITableViewDataSource, UITableViewDelegate{
@IBOutlet weak var myTableView : UITableView!
override func viewDidLoad(){
super.viewDidLoad()
myTableView.dataSource = self
myTableView.delegate = self
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 0
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cellTypeIdentifier", for: indexPath)
cell.textLabel!.text = "Cell text"
return cell
} }
wouldn't be easier if the methods present in the protocol (in this case the datasource and the UItableviewdelegate) were already into the UITableViewClass?