One of the changes I made to Runner’s Log recently is a small update to some drawing code to better match the new look and feel of Leopard. Since I’m still supporting OS X 10.4, I had to determine at run time what operating system I’m running under. There are a few ways to do this, but the best method I found was to use the Gestalt system call:
SInt32 version = 0;
Gestalt( gestaltSystemVersion, &version );
if ( version >= 0x1050 )
{
// New Leopard specific drawing code.
}
else
{
// Old drawing code.
}
Easy enough; see this Cocoadev page for more information, including checking for older versions of Mac OS X. If it’s just API calls in the operating system you’re worried about, you can just check the function pointer for a null value before calling it. See the Cross-Development Programming Guide for more information.
1 response so far ↓
You should use gestaltSystemVersion selector with care as it will not works as expected with version like 10.4.10 (minor or bugfix > 9).
I know you don’t need it in your case, but you may also use gestaltSystemVersionMajor ,gestaltSystemVersionMinor, and gestaltSystemVersionBugFix selectors to obtains the System version in a more reliable way.