Tevfik Xung
Tevfik Xung

Reputation: 978

Overriding method with selector "tableview:cellForRowAtIndexPath

When I try to build in Xcode 6 GM, I get this error:

overriding method with selector "tableview:cellForRowAtIndexPath

override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell? *** {
    let cell = tableView!.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath!) as UITableViewCell

    var toDoItem:NSDictionary = toDoItems.objectAtIndex(indexPath!.row) as NSDictionary
     cell.textLabel?.text = toDoItem.objectForKey("itemTitle") as? String


    return cell
}

Upvotes: 1

Views: 2026

Answers (1)

Mike S
Mike S

Reputation: 42335

The signature for that method changed in Xcode 6 GM. It should be:

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

Which would make your function look like:

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell

    var toDoItem:NSDictionary = toDoItems.objectAtIndex(indexPath.row) as NSDictionary
     cell.textLabel?.text = toDoItem.objectForKey("itemTitle") as? String


    return cell
}

Upvotes: 4

Related Questions