最近开始看书自学 xcode (swift)
之前没有其他基础,学得有点辛苦
书籍:ios 10 app 程式设计实力超进化攻略
现在学到UIAlertController
里面有一段闭包的应用说明:
let callActionHandler = { (action:UIAlertAction!) -> Void in
let alertMessage = UIAlertController(title: "Service Unavailable", message: "Sorry, the call feature is not available yet. Please retry later.", preferredStyle: .alert)
alertMessage.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
self.present(alertMessage, animated: true, completion: nil )
}
书中又教了另一种形式 (上面说推荐,比较简洁)
但是不是用上面那个设定去介绍
let checkInAction = UIAlertAction(title: "Check in", style: .default, handler:
{
(action:UIAlertAction!) -> Void in
let cell = tableView.cellForRow(at : indexPath)
cell?.accessoryType = .checkmark
})
optionMenu.addAction(checkInAction)
我想了一个晚上一直没有将第一种转成第二种的形式
想请问各位该如何将第一种转成下面那种比较简洁的语法