Skip to content

Instantly share code, notes, and snippets.

@ashleymills
Created June 18, 2015 13:24
Show Gist options
  • Save ashleymills/c37efb46c9dbef73d5dd to your computer and use it in GitHub Desktop.
Save ashleymills/c37efb46c9dbef73d5dd to your computer and use it in GitHub Desktop.
UIApplication category to get app version / build
@implementation UIApplication (AppVersion)
+ (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;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment