selector

Use this attribute to attach an Objective-C selector to a method.

This is a special compiler recognized attribute, it has several requirements, which all will be enforced by the compiler:

  • The attribute can only be attached to methods or constructors which have Objective-C linkage. That is, a method or a constructor in a class or interface declared as
    extern(Objective-C)
    .
  • It cannot be attached to a method or constructor that is a template
  • The number of colons in the string need to match the number of arguments the method accept.
  • It can only be used once in a method declaration
version(UdaSelector)
struct selector {
string selector;
}

Examples

extern (Objective-C)
class NSObject
{
 this() @selector("init");
 static NSObject alloc() @selector("alloc");
 NSObject initWithUTF8String(in char* str) @selector("initWithUTF8String:");
 ObjcObject copyScriptingValue(ObjcObject value, NSString key, NSDictionary properties)
     @selector("copyScriptingValue:forKey:withProperties:");
}

Meta