I have a parent view UIViewController (on storyboard), a TableViewController with .xib and TableViewCell with .xib. I am trying to connect DataSource to the TableView howev
When a class inherits from UITableViewController
, it by default conforms to UITableViewDataSource
& UITableViewDelegate
and you need not explicitly specify it.
You need to conform to UITableViewDataSource
and UITableViewDelegate
only when you embed a UITableView
in a UIViewController
.
There are at least 2 conformations in your class. You need to extend only once.
First Scenario:
You conform in the class description AND in the extension.
class MyViewController: MyDelegate{
//class functions here
}
extension MyViewController: MyDelegate{
func1()
}
Remove "My Delegate" in the class description.
class MyViewController{
//class functions here
}
extension MyViewController: MyDelegate{
func1()
}
Second Scenario:
You conform in two extensions.
extension MyViewController: MyDelegate{
func1()
}
extension MyViewController: MyDelegate{
func2()
}
Merge them into one extension like:
extension MyViewController: MyDelegate{
func1()
func2()
}