【发布时间】:2016-08-05 03:29:34
【问题描述】:
似乎有 3 种不同的方式来编写 UIAlertAction 的处理程序。以下每一项似乎都在做我希望他们做的相同/预期的事情
// 1.
let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) -> Void in
print("a")
})
// 2.
let okAction = UIAlertAction(title: "OK", style: .Default, handler: { (action: UIAlertAction!) in
print("b")
})
// 3.
let okAction = UIAlertAction(title: "OK", style: .Default) { (action) in
print("c")
}
// OUTPUT:
// a
// b
// c
这些都是处理程序吗?有什么区别,哪一种最好用?
【问题讨论】:
-
这个链接应该对stackoverflow.com/questions/24190277/…有帮助
-
@gurmandeep 谢谢。我仍然想了解为什么 3. 是最好的以及它们之间的区别是什么
标签: ios swift handler uialertcontroller