Selector Literal Expressions (Cocoa)

The selector keyword can be used to get a selector reference on Cocoa, for example to dynamically invoke methods, or pass them to Cocoa APIs that expecta aSEL type.

var s: SEL := selector(compare:options:);

Using the selector literal syntax will cause the compiler to perform checks if the specified selector is valid and known, and a warning will be emitted if a selector name is provided that does not match any method known to the compiler. This provides extra safely over using the NSSelectorFromString function.

Cocoa Only

The selector keyword is relevant and available on the Cocoa platform only.

See Also