mardi 23 juin 2015

Getting error in Xcode type "ViewController" does not conform to protocol"UITableViewDataSource"

I'm trying to follow a table views tutorial but I'm getting an error on the line of my class declaration which says: "type "ViewController" does not conform to protocol"UITableViewDataSource"" here is my code:

import UIKit

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

    private let dwarves = ["Sleepy", "Sneezy", "Bashful", "Happy", "Doc", "Grumpy", "Dopey", "Thorin", "Dorin", "Nori", "Ori", "Balin", "Dwalin", "Fili", "Kili", "Oin", "Gloin", "Bifur", "Bofur", "Bombur"]

    let simpleTableIdentifier = "SimpleTableIdentifier"

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCellWithIdentifier(simpleTableIdentifier) as? UITableViewCell
        if cell == nil {
            cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: simpleTableIdentifier)
        }

        cell!.textLabel!.text = dwarves[indexPath.row]
        return cell!
    }


}

See more ..

Aucun commentaire:

Enregistrer un commentaire