您的位置:首页 > 移动开发

ios判断app是否第一次使用

2015-10-10 17:29 274 查看
- (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];
}

[self.window makeKeyAndVisible];
return YES;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: