Skip to content

Instantly share code, notes, and snippets.

@cwagdev
Created March 13, 2015 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwagdev/0b6725c020d63900fc2f to your computer and use it in GitHub Desktop.
Save cwagdev/0b6725c020d63900fc2f to your computer and use it in GitHub Desktop.
UIApplication Extension for Version and App Name
extension UIApplication {
class var versionString: String {
get {
if let bundleInfoDictionary = NSBundle.mainBundle().infoDictionary {
let buildVersionString = bundleInfoDictionary["CFBundleVersion"] as String
let marketingVersionString = bundleInfoDictionary["CFBundleShortVersionString"] as String
return marketingVersionString + " (\(buildVersionString))"
} else {
return "Unknown"
}
}
}
class var appName: String {
get {
if let bundleInfoDictionary = NSBundle.mainBundle().infoDictionary {
let name = bundleInfoDictionary["CFBundleDisplayName"] as String
return name
} else {
return "Unknown"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment