views:

66

answers:

2

How would I be able to get the OSX version in objective-c? I would like to avoid using shell commands. E.g "10.5" or "10.4"

+1  A: 
NSProcessInfo *pinfo = [NSProcessInfo processInfo];
NSString *version = [pinto operatingSystemVersionString];

Sorry for the formatting, I'm using my iPad to answer this.

ennuikiller
That's fine if you want to display the version to the user, but not fine if you want to do processing based on the OS version.
JeremyP
I'll look into this, thanks for the answer!
alexy13
This works, but there is a lot of "garbage" text that is added with it (Build information etc).
alexy13
+1  A: 

You can use the Gestalt function to access the components of the OS version.

Old-time users of Gestalt may be amazed to find that it is still available in 64-bit.

Peter Hosey