Created
February 12, 2016 18:02
-
-
Save mingsai/0daf7f20b3e72824d3f8 to your computer and use it in GitHub Desktop.
A Swift extension to provide application version numbers and commonly used global constants
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
| // | |
| // MNGApplicatioNExtensions.swift | |
| // | |
| // | |
| // Created by Tommie N. Carter, Jr., MBA on 6/22/15. | |
| // Copyright © 2015 MING Technology. All rights reserved. | |
| // | |
| import UIKit | |
| import iAd | |
| let userdefaults = NSUserDefaults.standardUserDefaults() | |
| let defaultCenter = NSNotificationCenter.defaultCenter() | |
| let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate | |
| extension UIApplication { | |
| private struct Constants { | |
| static let CFBundleShortVersionString = "CFBundleShortVersionString" | |
| } | |
| class func appVersion() -> String { | |
| return NSBundle.mainBundle().objectForInfoDictionaryKey(Constants.CFBundleShortVersionString) as! String | |
| } | |
| class func appBuild() -> String { | |
| return NSBundle.mainBundle().objectForInfoDictionaryKey(kCFBundleVersionKey as String) as! String | |
| } | |
| class func versionBuild() -> String { | |
| let version = appVersion(), build = appBuild() | |
| return version == build ? "v\(version)" : "v\(version)(\(build))" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment