你们有没有这样的需求,每次升级APP后启动需要跳转到登录页。
实现代码如下:
#define APP_VERSION (NSString *)[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
- (BOOL)isFirstLoad {
NSString *currentVersion = APP_VERSION;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *lastRunVersion = [defaults objectForKey:LAST_RUN_VERSION_KEY];
if (!lastRunVersion) {
[defaults setObject:currentVersion forKey:LAST_RUN_VERSION_KEY];
[defaults synchronize];
return YES;
// App is being run for first time
} else if (![lastRunVersion isEqualToString:currentVersion]) {
[defaults setObject:currentVersion forKey:LAST_RUN_VERSION_KEY];
[defaults synchronize];
return YES;
// App has been updated since last run
}
return NO;
}
网友评论