Reputation: 5829
In my app I have class defined as follows:
class MyTableViewController: UITableViewController {
and inside I wanted to add the functionality of swiping selected cells (taken from this answer)
But when I write there this:
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
let more = UITableViewRowAction(style: .Normal, title: "More") { action, index in
print("more button tapped")
}
more.backgroundColor = UIColor.lightGrayColor()
let favorite = UITableViewRowAction(style: .Normal, title: "Favorite") { action, index in
print("favorite button tapped")
}
favorite.backgroundColor = UIColor.orangeColor()
let share = UITableViewRowAction(style: .Normal, title: "Share") { action, index in
print("share button tapped")
}
share.backgroundColor = UIColor.blueColor()
return [share, favorite, more]
}
I'm getting error:
Method 'tableView(:editActionsForRowAtIndexPath:)' with Objective-C selector 'tableView:editActionsForRowAtIndexPath:' conflicts with method 'tableView(:editActionsForRowAtIndexPath:)' from superclass 'UITableViewController' with the same Objective-C selector
I tried to add override
but it didn't help - what causes this error and how can I fix it?
Upvotes: 2
Views: 1414
Reputation: 21536
The signature is slightly different: the return value should be [UITableViewRowAction]?
not [AnyObject]?
:
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]?
You need the override
as well.
Upvotes: 6