// *** было: ***
// метод называли строкой; опечатка или переименование обнаруживались, только
// когда нажимали кнопку, и приложение падало
button.addTarget(self, action: "buttonTapped:",
forControlEvents: .TouchUpInside)
let timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self,
selector: "tick", userInfo: nil, repeats: true)
// *** в версии 2.2: ***
button.addTarget(self, action: #selector(buttonTapped(_:)),
forControlEvents: .TouchUpInside)
let timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self,
selector: #selector(tick), userInfo: nil, repeats: true)
// компилятор проверяет, что такой метод существует и виден Objective-C
func buttonTapped(sender: AnyObject) { }
func tick() { }
// если у двух методов одно имя, нужный выбирают по типу
let action = #selector(((tick) as () -> Void))