When I run this piece of code:

// FROM: https://dlang.org/spec/objc_interface.html
module main;

extern (Objective-C)
interface Class
{
  NSString alloc() @selector("alloc");
}

extern (Objective-C)
interface NSString
{
NSString initWithUTF8String(in char* str) @selector("initWithUTF8String:");
  void release() @selector("release");
}

extern (C) void NSLog(NSString, ...);
extern (C) Class objc_lookUpClass(in char* name);

void main()
{
  auto cls = objc_lookUpClass("NSString");
  auto str = cls.alloc().initWithUTF8String("Hello World!");
  NSLog(str);
  str.release();
}

I get this error:

$ dmd -L-framework -LFoundation test.d
test.d(7): Error: undefined identifier 'selector'
test.d(13): Error: undefined identifier 'selector'
test.d(14): Error: undefined identifier 'selector'

It just doesn't like that @selector statement. What's the catch?

Reply via email to