Can't get Objective-C class method to compile.

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Thu Dec 31 00:56:07 PST 2015


On Thursday, 31 December 2015 at 03:43:58 UTC, Jeremie Pelletier 
wrote:

> This is from the class method call to NSProcessInfo.processInfo.
>
> I've tried without the selector but get a linker error on 
> __D4main13NSProcessInfo11processInfoYZC4main13NSProcessInfo.
>
> I'm not sure if it is a bug or if I'm not using it correctly so 
> I'm asking here before opening a bug report :)

D doesn't support Objective-C classes methods yet. But as a 
workaround you can look how it's done with the "alloc" method in 
the documentation [1]. Declare the method as a non-static method 
but use the result from "objc_lookUpClass" as the receiver 
(object).

[1] http://dlang.org/spec/objc_interface.html#usage-example


More information about the Digitalmars-d mailing list