Re: Determining OS at Runtime
Re: Determining OS at Runtime
- Subject: Re: Determining OS at Runtime
- From: "Adam R. Maxwell" <email@hidden>
- Date: Fri, 03 Jul 2009 10:22:21 -0700
On Jul 3, 2009, at 10:06 AM, Steve Christensen wrote:
For the case of a function, if you're deploying on 10.4 but using a
10.5 function, that function will be weak-linked so doing a runtime
check is both faster and more accurate in determining whether a
function exists or not. For a Cocoa class method, you could replace
the test with a call to -respondsToSelector: to determine if it
exists or not. In both cases you're taking a feature-based approach
rather than a "I know this feature showed up in this OS version"
approach.
Just as a caution, you may run across functions that don't have the
appropriate weak attribute in the header, so you'll crash at launch
time on 10.4 (this bit me recently with CFStringTokenizer, rdar://problem/6781636
) So if you're checking function pointers against NULL, check the
header to make sure they have the correct accessibility macro.
--
Adam
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden