-
-
Save trfiladelfo/e27375d7467a7333a0e8fe2577b25cfd to your computer and use it in GitHub Desktop.
UIApplication category to get app version / build
This file contains hidden or 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