UIAlertActionのハンドラを書く方法は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
これらはすべてハンドラを作成していますか?どのような違いがあり、使用するのがベストですか?
のように、このリンクはhttp://stackoverflow.com/questions/24190277/writing-handler-for-uialertaction – gurmandeep
@gurmandeep感謝を助けるべきであることを言及する必要があります。私はまだ3が最高だと理解したいと思っています。それらの間の違いはすべて – rdk
です。私は@Joeyに同意します。詳細はhttps://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAlertAction_Class/ – gurmandeep