Re: Detect legacy OSX
Re: Detect legacy OSX
- Subject: Re: Detect legacy OSX
- From: David Duncan <email@hidden>
- Date: Wed, 22 Aug 2007 12:48:54 -0700
On Aug 21, 2007, at 4:59 PM, Andrew James wrote:
I am trying to find a method to detect if the OS version is less
than 10.4, however i do not want to block 10.5 and such users as
well as the OS version is retrieved as 10.x.xx so a simple < will
not work.
In some sample code that I'm working on, I use the following to
detect if I'm running on 10.5 or later or not
// This function checks if we are running on 10.5 or later
BOOL RunningOn105OrLater()
{
// Assume that we are running on Mac OS X 10.4 until we actually
test for it.
static BOOL tested = NO, tenFiveOrLater = NO;
if(!tested)
{
// Assuming 10.4.0 should we get any errors from Gestalt.
SInt32 major = 10, minor = 4, bugfix = 0;
Gestalt(gestaltSystemVersionMajor, &major);
Gestalt(gestaltSystemVersionMinor, &minor);
Gestalt(gestaltSystemVersionBugFix, &bugfix);
tenFiveOrLater = (major > 10) || ((major == 10) && (minor >= 5));
tested = YES;
}
return tenFiveOrLater;
}
Two things about this code
1) The Gestalt selectors that I'm using only exist on 10.3 or later.
You can detect this by checking for errors (which I do not here) and
use an alternate selector (gestaltSystemVersion) in that case.
2) Checking the OS version in order to detect features is a technique
of LAST resort. You should explicitly test for the features you
desire instead. In the sample that I'm using this in, it is used as a
technique of last resort :).
And please don't parse the SystemVersion property list - it is too
easy to get that wrong :).
--
David Duncan
Apple DTS Quartz and Printing
email@hidden
_______________________________________________
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