iOS开发中判断是不是首次登录或者版本更新

判断是不是首次登录或者版本更新

-(BOOL )isFirstLauch{
//获取当前版本号
NSDictionary infoDic = [[NSBundle mainBundle] infoDictionary];
NSString
currentAppVersion = infoDic[@"CFBundleShortVersionString"];
//获取上次启动应用保存的appVersion
NSString *version = [[NSUserDefaults standardUserDefaults] objectForKey:kAppVersion];
//版本升级或首次登录
if (version == nil || [version isEqualToString:currentAppVersion]) {
[[NSUserDefaults standardUserDefaults] setObject:currentAppVersion forKey:kAppVersion];
[[NSUserDefaults standardUserDefaults] synchronize];
return YES;
}else{
return NO;
}
}

可以在application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions中做一些启动方面 的操作

转载于:https://www.cnblogs.com/BigerThanBiger/p/8567903.html

你可能感兴趣的:(iOS开发中判断是不是首次登录或者版本更新)