How to check Mac OS X version at runtime

前端 未结 5 1257
孤街浪徒
孤街浪徒 2021-01-12 22:48

I am using below code to check OS X version at runtime.

if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_10)
{
    /* On a 10.10.x or earlier s         


        
5条回答
  •  离开以前
    2021-01-12 23:17

    Update:

    Use #define NSAppKitVersionNumber10_10_Max 1349

    Old:

    From 10.11 SDK

    #define NSAppKitVersionNumber10_7_2 1138.23
    #define NSAppKitVersionNumber10_7_3 1138.32
    #define NSAppKitVersionNumber10_7_4 1138.47
    #define NSAppKitVersionNumber10_8 1187
    #define NSAppKitVersionNumber10_9 1265
    #define NSAppKitVersionNumber10_10 1343
    #define NSAppKitVersionNumber10_10_2 1344
    #define NSAppKitVersionNumber10_10_3 1347
    

    for 10.10.4 Its 1348.0(From NSLog output)

    They increase decimal part for 10.10.x constant.

    The workaround is to use CFBundleVersion value /System/Library/Frameworks/AppKit.framework/Resources/Info.plist on 10.11.

    if (NSAppKitVersionNumber < 1391.12)
    {
        /* On a 10.10.x or earlier system */
    }
    

    NOTE: My OS X 10.11 build version is 15A244a. If someone have first build , Please update the value in if condition.

提交回复
热议问题