[Mono-osx] external reference to a class
Duane Wandless
duane at wandless.net
Fri Nov 6 17:49:51 EST 2009
That is much better... thank you for suggesting this.
Duane
On Fri, Nov 6, 2009 at 2:53 AM, Laurent Etiemble <laurent.etiemble at gmail.com
> wrote:
> Hello,
>
> Why don't you use the "NSClassFromString" function
> (
> http://developer.apple.com/mac/library/documentation/cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSClassFromString
> )
> ? The return type is a Class instance, and is not as low-level as a
> call to objc_getClass().
>
> [NSClassFromString(@"MyMonoClass") testTouch];
>
> Note 1: See http://www.cocoadev.com/index.pl?NSClassFromString for more
> comments
> Note 2: you can even define a macro to avoid the cluttering of your code.
>
> Regards, Laurent Etiemble.
>
> 2009/10/22 Duane Wandless <duane at wandless.net>:
> > Hopefully someone can help with this.
> >
> > I am currently doing this.
> >
> > id myobj = objc_getClass("MyMonoClass");
> > [myobj testTouch];
> >
> > which works. MyMonoClass is not defined so I cannot do this:
> > [MyMonoClass testTouch];
> >
> > Because the compiler tries to resolve the class reference, of course.
> >
> > Is there a better way to do this than what I have? Which I got the idea
> of
> > how to do this from Monobjc!
> >
> > The context is that I have a Cocoa application that loads the mono
> runtime
> > which loads my Monobjc enabled library. Which that is where MyMonoClass
> is
> > defined. Then I need to invoke a method on the mono class from Cocoa.
> >
> > Thanks,
> > Duane
> >
> > _______________________________________________
> > Mono-osx mailing list
> > Mono-osx at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-osx
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20091106/3825c083/attachment.html
More information about the Mono-osx
mailing list