How do I get the current version of my iOS project in code?

后端 未结 8 1326
挽巷
挽巷 2020-12-12 10:23

I would like to be able to get the current version of my iOS project/app as an NSString object without having to define a constant in a file somewhere. I don\'t

8条回答
  •  独厮守ぢ
    2020-12-12 11:12

    In Swift, you can get bundle version by using:

    let info:NSDictionary = NSBundle.mainBundle().infoDictionary!
    
    let version:String = info.objectForKey("CFBundleShortVersionString") as! String
    
    versionLabel.text = "Version:" + version
    

提交回复
热议问题