版本新特性(在程序启动的时候判断是否是新版本)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    //1.不用storyboard,在这里设置窗口的根控制器
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds]];
    
    NSString *key = @"CFBundleVersion";
    //取出沙盒中存储的上次使用的版本号
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *lastVersion = [defaults stringForKey:key];
  
    //获得当前软件的版本号
    NSString *currentVersion = [NSBundle mainBundle].infoDictionary[key] ;
    
    if ([currentVersion isEqualToString:lastVersion]) {
        //0.显示状态栏
        application.statusBarHidden = NO;
        self.window.rootViewController = [[TabBarViewController alloc]init];
    }else{
        self.window.rootViewController = [[NewfeatureController alloc]init];
        //存储新版本
        [defaults setObject:currentVersion forKey:key];
        [defaults synchronize];
    }
    
    [self.window makeKeyAndVisible];
    
    return YES;
}

你可能感兴趣的:(iOS)