Skip to content

Instantly share code, notes, and snippets.

@ariok
Created July 7, 2015 09:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ariok/2b64150f2fef1ee73df8 to your computer and use it in GitHub Desktop.
Save ariok/2b64150f2fef1ee73df8 to your computer and use it in GitHub Desktop.
[swift] Extend NSBundle to get Version and Build info
extension NSBundle {
class var versionNumber: String {
if let version = NSBundle.mainBundle().infoDictionary?["CFBundleShortVersionString"] as? String {
return version
}
return "N.D."
}
class var buildNumber: String {
if let build = NSBundle.mainBundle().infoDictionary?["CFBundleVersion"] as? String {
return build
}
return "N.D."
}
class var versionAndBuild: String{
return "\(NSBundle.versionNumber)-\(NSBundle.buildNumber)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment