Since previous answers were polluted with older versions of Swift and unrelated answers, I will try to ask this question more precisely:
Does Swift 2.0 have a type selector or a way at compile time to create a selector from a function, not a string?
If the answer is no, please provide documentation for the answer. If yes, provide an example.
I know about closures, however, using closures is not an option for the Cocoa API with Objective-C compatibility.
func init()
{
someCall("quit")
someCall(quit)
}
func someCall(selector : Selector) { ...}
func quit() { ...}
source
share