1. 程式人生 > >框架——是否為新版本

框架——是否為新版本

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
    
    NSString *key = (NSString *)kCFBundleVersionKey;
    
    // 1.從Info.plist中取出版本號
    NSString *version = [NSBundle mainBundle].infoDictionary[key];
    
    // 2.從沙盒中取出上次儲存的版本號
    NSString *saveVersion = [[NSUserDefaults standardUserDefaults] objectForKey:key];
    
    if ([version isEqualToString:saveVersion]) { // 不是第一次使用這個版本
        // 顯示狀態列
        application.statusBarHidden = NO;
        
        self.window.rootViewController = [[MainController alloc] init];
    } else { // 版本號不一樣:第一次使用新版本
        // 將新版本號寫入沙盒
        [[NSUserDefaults standardUserDefaults] setObject:version forKey:key];
        [[NSUserDefaults standardUserDefaults] synchronize];
        
        // 顯示版本新特性介面
        self.window.rootViewController = [[NewfeatureController alloc] init];
    }
    NSLog(@"key=%@,version=%@,infoDictionary=%@,saveVersion=%@,standardUserDefaults=%@",key,version,[NSBundle mainBundle].infoDictionary,saveVersion,[NSUserDefaults standardUserDefaults]);
    [self.window makeKeyAndVisible];
    return YES;
}

key=CFBundleVersion,version=1.0,infoDictionary={

    CFBundleDevelopmentRegion = en;

    CFBundleDisplayName = "\U65b0\U6d6a\U5fae\U535a";

    CFBundleExecutable = "\U65b0\U6d6a\U5fae\U535a";

    CFBundleIdentifier = "cn.itcast.----";

    CFBundleInfoDictionaryVersion = "6.0";

    CFBundleInfoPlistURL = "Info.plist -- file:///Users/dongjw/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/F5E547C6-B809-4052-8C6F-CD9439D95998/%E6%96%B0%E6%B5%AA%E5%BE%AE%E5%8D%9A.app/";

    CFBundleName = "\U65b0\U6d6a\U5fae\U535a";

    CFBundleNumericVersion = 16809984;

    CFBundlePackageType = APPL;

    CFBundleShortVersionString = "1.0";

    CFBundleSignature = "????";

    CFBundleSupportedPlatforms =     (

        iPhoneSimulator

    );

    CFBundleVersion = "1.0";

    DTPlatformName = iphonesimulator;

    DTSDKName = "iphonesimulator7.1";

    LSRequiresIPhoneOS = 1;

    UIDeviceFamily =     (

        1

    );

    UIPrerenderedIcon = 1;

    UIRequiredDeviceCapabilities =     (

        armv7

    );

    UIStatusBarHidden = 1;

    UISupportedInterfaceOrientations =     (

        UIInterfaceOrientationPortrait

    );

},saveVersion=1.0,standardUserDefaults=<NSUserDefaults: 0x8f768a0>