infernouk infernouk - 26 days ago 8
Swift Question

Does Not Conform To Protocol 'UITableViewDataSource' Error?

I am trying to set up my table view, I am using

class ExerciseDatabaseController: UIViewController, UITableViewDataSource, UITableViewDelegate {


I am then using the mandatory functions:

func ExerciseDatabaseController(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath as IndexPath)
return cell
}


and

func ExerciseDatabaseController(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 0
}


as per the apple guidelines: https://developer.apple.com/reference/uikit/uitableviewdatasource

I cant work out why I am still having non conforming protocol errors for this class?


Type 'ExerciseDatabaseController' does not conform to protocol 'UITableViewDataSource'

ohr ohr
Answer

If you start typing the name of the functions Xcode will auto-complete them for you. Here's an example that'll help you. (And doc. in the link)

 func numberOfSectionsInTableView(tableView: UITableView) -> Int
    {
        return 1
    }
Comments