關於[[NSBundle mainBundle] infoDictionary]裏面的那些東西

在開發中, 假如我們設置啓動頁面的時候, 需要判讀一下我們的應用是不是第一次啓動,或者 是不是版本的升級。然而我們需要在程序中,通過

//獲取當前版本號

    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];

    NSLog(@"%@",infoDic);

    NSString *currentAppVersion = infoDic[@"CFBundleShortVersionString"];


infoDic包含如下所有的信息:也就是我們的程序信息:

{


 BuildMachineOSBuild = 15C50;

    CFBundleDevelopmentRegion = en;

    CFBundleExecutable = ZYGLaunchIntroductionDemo;

    CFBundleIdentifier = "com.huaxinlongma.ZYGLaunchIntroductionDemo";

    CFBundleInfoDictionaryVersion = "6.0";

    CFBundleInfoPlistURL = "Info.plist -- file:///Users/lanouhn/Library/Developer/CoreSimulator/Devices/84454B75-C87C-4752-A24B-095EAAC00443/data/Containers/Bundle/Application/09AB9754-B19E-4F63-869B-B8D6C319EE85/ZYGLaunchIntroductionDemo.app/";

    CFBundleName = ZYGLaunchIntroductionDemo;

    CFBundleNumericVersion = 16809984;

    CFBundlePackageType = APPL;

    CFBundleShortVersionString = "1.0";

    CFBundleSignature = "????";

    CFBundleSupportedPlatforms =     (

        iPhoneSimulator

    );

    CFBundleVersion = 1;

    DTCompiler = "com.apple.compilers.llvm.clang.1_0";

    DTPlatformBuild = "";

    DTPlatformName = iphonesimulator;

    DTPlatformVersion = "9.2";

    DTSDKBuild = 13C75;

    DTSDKName = "iphonesimulator9.2";

    DTXcode = 0720;

    DTXcodeBuild = 7C68;

    LSRequiresIPhoneOS = 1;

    MinimumOSVersion = "8.1";

    UIDeviceFamily =     (

        1

    );

    UILaunchStoryboardName = LaunchScreen;

    UIRequiredDeviceCapabilities =     (

        armv7

    );

    UISupportedInterfaceOrientations =     (

        UIInterfaceOrientationPortrait,

        UIInterfaceOrientationLandscapeLeft,

        UIInterfaceOrientationLandscapeRight

    );

}

這些並不是我們在程序info.plist 看到的那些key 值。很多都是 以BF爲key 來進行字典的存儲。

 //獲取上次啓動應用保存的appVersion

    NSString *version = [[NSUserDefaults standardUserDefaults] objectForKey:kAppVersion];


從沙河中獲取我們上次啓動的版本號。當version = nil;  這時候 可以 判斷是第一次登陸。假如

[version isEqualToString:currentAppVersion]; 這時候 來判斷是不是一個版本號 進行相應的實現。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章