ios - How do I get the App version and build number using Swift? -


i have ios app azure back-end, , log events, logins , versions of app users running.

how can return version , build number using swift?

edit

as pointed out @azdev on new version of xcode compile error trying previous solution, solve edit suggested unwrap bundle dictionary using !

let nsobject: anyobject? = nsbundle.mainbundle().infodictionary!["cfbundleshortversionstring"] 

end edit

just use same logic in objective-c small changes

//first nsobject defining optional anyobject let nsobject: anyobject? = nsbundle.mainbundle().infodictionary["cfbundleshortversionstring"]  //then cast object string, careful, may want double check nil let version = nsobject string 

i hope helps out.

david


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -