Objective-C的@selector在Swift中用Selector结构体来替代。在Swift中,我们可以使用字符串常量来构造Selector,例如:
let mySelector: Selector = "tappedButton:"
因为字符串最终会被自动转换成Selector。下面是一个例子:
// Swift myButton.addTarget(self, action: "buttonTapped:", forControlEvents: .TouchUpInside) func buttonTapped(sender: UIButton!) { // custom code... }
:-]
原文地址:http://blog.csdn.net/tounaobun/article/details/40679577