简体   繁体   中英

How can I access version of the app within Settings.bundle like it is in info.plist?

Some of the variables are accesses from within Info.plist file like $(VARIABLE):

在此处输入图片说明

Is it possible to do the same in Settings.bundle?

I need to display there my current ios app version:

在此处输入图片说明

You cannot dynamically change the Settings.bundle. Settings.bundle always use static plist.

But you can change it using NSUserDefaults

在此处输入图片说明

//Set app version
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setValue:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] forKey:@"appVersion"];
[defaults synchronize];

You can put above code to:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM