-1

Possible Duplicate:
Find Mac OS X version number in objective c

My application needs to be run on (10.5,10.6,10.7) . I have some different implementation pieces for each of them. So I want to be able to check OSX version from my APP.

How can I do it?

What is the best way to do that? Is there any function like if([osx version])...?

P.S. I'm aware of this question How can I determine the running Mac OS X version programmatically? I just couldn't find what I want for all that 3 versions.

Thanks a lot

Community
  • 1
  • 1
User1234
  • 2,362
  • 4
  • 27
  • 57
  • I was aware only http://stackoverflow.com/questions/157759/how-can-i-determine-the-running-mac-os-x-version-programmatically question. But your link seems to be only for 10.6 – User1234 Oct 13 '11 at 19:07
  • 10.6.7 was an example of version string; ‘e.g.’ means ‘for example’. There’s nothing in the answer that’s specific to an OS X version. –  Oct 13 '11 at 19:09
  • If the different implementations depend on what APIs are available you should probably check for features instead of OS versions. For example "if (![someInstance respondsToSelector:@selector(fooBar:withMoarArgs:)]) { [someInstance foo:a withMoarArgs:b] } else { custom implementation }". Edit: Which is also what Graham Lee said in the thread you linked to at http://stackoverflow.com/questions/157759/how-can-i-determine-the-running-mac-os-x-version-programmatically/159927#159927 – rastersize Oct 13 '11 at 19:14
  • This might be a useful [Link](http://cocoadevcentral.com/articles/000067.php) or [this](http://stackoverflow.com/questions/2115373/os-version-checking-in-cocoa) – Johan_ Oct 13 '11 at 18:56

1 Answers1

1

I use gestalt in one of my Apps succesfuly. Some code snippet to check wether the user is running 10.7.0 or higher:

SInt32 OSXversionMajor, OSXversionMinor;
if(Gestalt(gestaltSystemVersionMajor, &OSXversionMajor) == noErr && Gestalt(gestaltSystemVersionMinor, &OSXversionMinor) == noErr)
{
    if(OSXversionMajor == 10 && OSXversionMinor >= 7)
    {
         // Foo
    }
}
JustSid
  • 25,168
  • 7
  • 79
  • 97