Last active
December 18, 2015 16:29
-
-
Save cokecoffe/5811637 to your computer and use it in GitHub Desktop.
Version check Tools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//将版本字符串转换为数字 | |
+(int)getVersionNumber:(NSString*)version | |
{ | |
int versionNo = 0; | |
NSArray *arr = [version componetsSeparateByString:@"."]; | |
int count = arr.count; | |
for(NSString *no in arr) | |
{ | |
versionNo += no.intValue*pow(10,--count); | |
} | |
return versionNo; | |
} | |
//检测当前是否是首次运行 | |
-(BOOL)isFirstRunning | |
{ | |
NSString *localVersion = [[NSUserDefaults standardUserDefaults] objectForKey:@"localVersion"]; | |
NSString *appVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; | |
if ([localVersion isEqualToString:appVersion]) { | |
return NO; | |
}else{ | |
[[NSUserDefaults standardUserDefaults]setObject:appVersion forKey:@"localVersion"]; | |
return YES; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment