Re: Cocoa Cross Development
Re: Cocoa Cross Development
- Subject: Re: Cocoa Cross Development
- From: "Alastair J.Houghton" <email@hidden>
- Date: Mon, 3 Nov 2003 23:24:16 +0000
On Monday, November 3, 2003, at 09:45 pm, Chris Hanson wrote:
The one downside of the way Cocoa and Mach-O are structured on Mac OS
X is that it's not trivial to build applications that make use of new
features when available, but don't when they're not. This is
something that is done very well in Carbon (and InterfaceLib) with CFM
via weak-linking and the Gestalt() call. I wish the same mechanism
were available in Cocoa.
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.
Also, if you want to use a Cocoa class and you aren't sure it will be
there, you can use the Objective-C runtime to query for it... e.g.
Class shadowClass = objc_lookUpClass("NSShadow");
NSShadow *shadow = nil;
if (shadowClass) {
shadow = [[shadowClass alloc] init];
} else {
NSLog(@"NSShadow doesn't exist here.\n");
}
See the Mach-O documentation and the Objective-C Programming Language
for more information on both of these.
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.