• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa Cross Development
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Cocoa Cross Development
      • From: Chris Hanson <email@hidden>
References: 
 >Re: Cocoa Cross Development (From: Chris Hanson <email@hidden>)

  • Prev by Date: Re: NSOutlineView and Controller layer
  • Next by Date: Re: Cocoa Cross Development
  • Previous by thread: Re: Cocoa Cross Development
  • Next by thread: Re: Cocoa Cross Development
  • Index(es):
    • Date
    • Thread