Skip to content

Instantly share code, notes, and snippets.

@tuchangwei
Created June 13, 2015 07:45
Show Gist options
  • Save tuchangwei/0d0387d4657ac5ea1447 to your computer and use it in GitHub Desktop.
Save tuchangwei/0d0387d4657ac5ea1447 to your computer and use it in GitHub Desktop.
+ (NSString *) appVersion
{
return [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleShortVersionString"];
}
+ (NSString *) build
{
return [[NSBundle mainBundle] objectForInfoDictionaryKey: (NSString *)kCFBundleVersionKey];
}
+ (NSString *) versionBuild
{
NSString * version = [self appVersion];
NSString * build = [self build];
NSString * versionBuild = [NSString stringWithFormat: @"v%@", version];
if (![version isEqualToString: build]) {
versionBuild = [NSString stringWithFormat: @"%@(%@)", versionBuild, build];
}
return versionBuild;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment