Skip to content

Instantly share code, notes, and snippets.

@sebk
Created July 3, 2014 17:54
Show Gist options
  • Save sebk/c37f8c27c8bd48500b67 to your computer and use it in GitHub Desktop.
Save sebk/c37f8c27c8bd48500b67 to your computer and use it in GitHub Desktop.
Read version infos from Info-plist
- (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