Reputation: 13
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
Upvotes: 0
Views: 33
Reputation: 42598
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.
Upvotes: 1