Re: Cocoa Cross Development
Re: Cocoa Cross Development
- Subject: Re: Cocoa Cross Development
- From: Chris Hanson <email@hidden>
- Date: Mon, 3 Nov 2003 17:43:33 -0600
On Nov 3, 2003, at 5:24 PM, Alastair J.Houghton wrote:
Mach-O has weak linking as of OS X 10.2 (just add
__attribute__((__weak_import__)) to your function prototype), and
Objective-C has the -respondsToSelector: and
+instancesRespondToSelector: messages, which let you test for a
particular feature in a class you've already got.
Yes, I know about those.
Class shadowClass = objc_lookUpClass("NSShadow");
NSShadow *shadow = nil;
if (shadowClass) {
shadow = [[shadowClass alloc] init];
} else {
NSLog(@"NSShadow doesn't exist here.\n");
}
I don't want to have to do this. I want to write the code this way:
NSShadow *shadow = nil;
if ([NSSystem supportsFeature:NSShadowFeature]) {
shadow = [[NSShadow alloc] init];
}
Or maybe this way:
NSShadow *shadow = nil;
if ([NSShadow class] != Nil) {
shadow = [[NSShadow alloc] init];
}
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? :)
-- Chris
--
Chris Hanson, bDistributed.com, Inc. | Email: email@hidden
Outsourcing Vendor Evaluation | Phone: +1-847-372-3955
Custom Mac OS X Development | Fax: +1-847-589-3738
http://bdistributed.com/ | Personal Email: email@hidden
_______________________________________________
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.