objective-ccocoamacos

Find Mac OS X version number in objective c


How can I find the version number of Mac OS X (eg. "10.6.7") from my Cocoa Objective-C application?


Solution

  • #import <CoreServices/CoreServices.h>
    
    SInt32 major, minor, bugfix;
    Gestalt(gestaltSystemVersionMajor, &major);
    Gestalt(gestaltSystemVersionMinor, &minor);
    Gestalt(gestaltSystemVersionBugFix, &bugfix);
    
    NSString *systemVersion = [NSString stringWithFormat:@"%d.%d.%d",
        major, minor, bugfix];