Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type 'ProfilesTableViewController' does not conform to protocol 'UITableViewDataSource' in Xcode 6 GM seed

Today I migrated to Xcode 6 GM seed and now I get the following error:

Type 'ProfilesTableViewController' does not conform to protocol 'UITableViewDataSource'.

I've overrided numberOfRowsInSection, cellForRowAtIndexPath and numberOfSectionsInTableView.
In fact everything worked fine till today. I noticed that when I remove UITableViewDataSource everything is working fine, and no errors occured. So .. Is it necessary to use 'UITableViewDataSource' anymore, or just override the functions from it?

like image 869
Hristo Atanasov Avatar asked Dec 01 '25 07:12

Hristo Atanasov


1 Answers

This code compiles fine:

class ProfileTableViewController: UITableViewController, UITableViewDelegate, UITableViewDataSource {


override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 1
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier("foo", forIndexPath: indexPath) as UITableViewCell

    return cell
}
}

So, you can definitely subclass UITableViewController and define its UITableViewDataSource protocol implementation.

Take notice that I am using the override keyword and also that I am not using auto-unwrapped arguments -- i.e., not like this:

override func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {

which was correct in previous Xcode 6 betas.

like image 87
sergio Avatar answered Dec 03 '25 19:12

sergio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!