• 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: Mac OS X Deployment Target
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mac OS X Deployment Target


  • Subject: Re: Mac OS X Deployment Target
  • From: "Paul Sanders" <email@hidden>
  • Date: Fri, 14 May 2010 14:59:39 +0100

> That's what weak linking is all about. It will fail only when you try to use that code on 10.4, therefore such use should always be put in a conditional statement checking for existence of the symbol (e.g. using respondsToSelector:).

Just to say, weak linking and respondsToSelector: are two different things.  Weak linking allows you to test whether a particular symbol (i.e. an exported function or variable) is present on the platform you are running on, e.g.:
 
    extern "C" void SomeFunction (void) WEAK_IMPORT_ATTRIBUTE;
    if (SomeFunction)
        SomeFunction ();
 
respondsToSelector: serves a similar purpose for methods by querying the tables built by the Objective-C runtime.  No symbols are involved and weak linking is not relevant here - you can use respondsToSelector: without using weak linking at all.
 
On a more practical note, I build against the 10.4 SDK since this will generate compiler warnings / errors if I inadvertenty use a function or method not available on 10.4.  Then, if I want to conditionally call a function or method only present on later platforms I prototype the function myself (using WEAK_IMPORT_ATTRIBUTE) or declare a category on the relevant class respectively.  This approach has trapped some potentially unpleasant coding mistakes.
 
Note that to use weak linking successfully, you need some additional linker flags: http://stackoverflow.com/questions/274753/how-to-make-weak-linking-work-with-gcc (see answer #1). This is not necessary if, as is more common, you are just using respondsToSelector:.
 
Paul Sanders.
 
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Mac OS X Deployment Target
      • From: Christiaan Hofman <email@hidden>
References: 
 >Mac OS X Deployment Target (From: Howard Rodstein <email@hidden>)
 >Re: Mac OS X Deployment Target (From: Chris Espinosa <email@hidden>)
 >Re: Mac OS X Deployment Target (From: Howard Rodstein <email@hidden>)
 >Re: Mac OS X Deployment Target (From: Christiaan Hofman <email@hidden>)

  • Prev by Date: Re: Mac OS X Deployment Target
  • Next by Date: Re: Mac OS X Deployment Target
  • Previous by thread: Re: Mac OS X Deployment Target
  • Next by thread: Re: Mac OS X Deployment Target
  • Index(es):
    • Date
    • Thread