0

How come it keeping showing me this message even though I type the right declaration of UITableViewRowAction?

var shareAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Share",
        handler: { (action:UITableViewRowAction!, indexPath: NSIndexPath) -> Void in
Shoaib
  • 2,286
  • 1
  • 19
  • 27

1 Answers1

1

The Xcode 6.4 documentation says both parameters should be implicitly unwrapped optionals.

var shareAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Share",
        handler: { (action: UITableViewRowAction!, indexPath: NSIndexPath!) -> Void in

or in Xcode 7, neither parameters are optional.

var shareAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Share",
        handler: { (action: UITableViewRowAction, indexPath: NSIndexPath) -> Void in

Either way, you should try

var shareAction = UITableViewRowAction(style: .Default, title: "Share") {
    action, indexPath in
    /* ... */
}

Which is a more swifty way of doing it.

Jeffery Thomas
  • 42,202
  • 8
  • 92
  • 117