- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//创建Window
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//判断要显示的Controller
//1.
NSString *versionKey = (NSString *)kCFBundleVersionKey;
//从Info.plst中取出版本号
NSString *version = [NSBundle mainBundle].infoDictionary[
versionKey];
//从沙盒中取出上次存储的版本号
NSString *saveVersion = [[NSUserDefaults standardUserDefaults] objectForKey:versionKey];
//2.判断
if ([version isEqualToString:saveVersion]) {
self.window.rootViewController = [[应用程序主页面控制器 alloc] init];
} else {
[[NSUserDefaults standardUserDefaults] setObject:version forKey:versionKey];
[[NSUserDefaults standardUserDefaults] synchronize];
//显示
self.window.rootViewController = [[引导页控制器 alloc] init];
}
[self.window makeKeyAndVisible];
return YES;
}
转载于:https://blog.51cto.com/fanyuecheng/1684020