How can I display the application version revision in my application's settings bundle?

前端 未结 13 793
一个人的身影
一个人的身影 2020-11-29 15:20

I would like to include the application version and internal revision, something like 1.0.1 (r1243), in my application\'s settings bundle.

The Root.plist file contai

13条回答
  •  失恋的感觉
    2020-11-29 15:40

    My lazy man's solution was to update the version number from my application code. You could have a default (or blank) value in the Root.plist and then, somewhere in your startup code:

    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
    [[NSUserDefaults standardUserDefaults] setObject:version forKey:@"version_preference"];
    

    The only catch is that your app would have to be run at least once for the updated version to appear in the settings panel.

    You could take the idea further and update, for instance, a counter of how many times your app has been launched, or other interesting bits of information.

提交回复
热议问题