infernouk infernouk - 1 year ago 61
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


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

as per the apple guidelines:

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 Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download