Created
July 3, 2014 17:54
-
-
Save sebk/c37f8c27c8bd48500b67 to your computer and use it in GitHub Desktop.
Read version infos from Info-plist
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
- (NSString *)versionText | |
{ | |
NSString *bundleVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; | |
NSString *buildNumber = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey]; | |
NSString *versionText; | |
if (bundleVersion) { | |
if (buildNumber) { | |
versionText = [NSString stringWithFormat:@"Version %@.%@", bundleVersion, buildNumber]; | |
} else { | |
versionText = [NSString stringWithFormat:@"Version %@", bundleVersion]; | |
} | |
} else { | |
if (buildNumber) { | |
versionText = [NSString stringWithFormat:@"Build %@", buildNumber]; | |
} | |
} | |
return versionText; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment