Created
June 18, 2015 13:24
-
-
Save ashleymills/c37efb46c9dbef73d5dd to your computer and use it in GitHub Desktop.
UIApplication category to get app version / build
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
@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