Re: Cocoa Cross Development
Re: Cocoa Cross Development
- Subject: Re: Cocoa Cross Development
- From: "Alastair J.Houghton" <email@hidden>
- Date: Tue, 4 Nov 2003 11:51:22 +0000
On Monday, November 3, 2003, at 11:43 pm, Chris Hanson wrote:
I don't want to have to clutter up my code with extraneous
NSClassFromString calls to write something that runs on both Jaguar
and Panther.
My impression was that this doesn't work by default in Mach-O with
Objective-C, because of how class & selector information is
maintained in the executable and configured at load time. Am I wrong?
(And if I am, just how wrong am I? :)
I think it's just that the line
shadow = [[NSShadow alloc] init];
attempts to directly access the NSShadow class by using its symbol,
rather than by going via the Objective C runtime. Almost certainly
this is for performance reasons.
You could always do something like
#define WEAK_CLASS(x) objc_lookUpClass( #x )
Then you could write
NSShadow *shadow = [[WEAK_CLASS(NSShadow) alloc] init];
which isn't *too* bad (although obviously not all that efficient, but
that could be improved by caching the class pointer).
Kind regards,
Alastair.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.