Detailed example of IOS obtaining app version number

Time:2022-5-25

Detailed example of IOS obtaining app version number

When I look at the code, I see a sentence for obtaining Version number of plist file


labelVersion.text = [NSString stringWithFormat:@"v%@", [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey]]; 

I’m interested in the latter parameter kcfbundleversionkey, which turns out to be CFBundle H has been set to a good attribute, and the following is the comment of this attribute


const CFStringRef kCFBundleVersionKey;
  /* The version number of the bundle. For Mac OS 9 style version numbers (for example "2.5.3d5"), */
  /* clients can use CFBundleGetVersionNumber() instead of accessing this key directly since that */
  /* function will properly convert the version string into its compact integer representation. */

There are also many standard info beginning with kcfxxx Plist keys attribute. If you are interested, you can take a look at CFBundle h. Study their usage,

The above is a simple example of IOS obtaining app version number. There are many articles on IOS development on this site. You can refer to them. Thank you for reading. I hope it can help you. Thank you for your support to this site!

Recommended Today

Root access method in docker container

First of all, your container must be running You can view the container ID of the container through sudo docker container LS or sudo docker PS Finally execute the command (7509371edd48 is the container ID found above) sudo docker exec -ti -u root 7509371edd48 bash Supplement: solve the problem that non root users do not […]