Swift: Selectors

Its very easy to use selectors in Swift. In Objective-C you would pass a selector to a method by using @selector(methodName). In Swift all you have to do is pass the method name as a string.


NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: “onTimer”, userInfo: nil, repeats: true)

This will call the onTimer function of self once per second.