![](/img/trans.png)
[英]The Copy Bundle Resources build phase contains this target's Info.plist file 'Info.plist' in xcode 6?
[英]Can Settings bundle use values from application's Info.plist file?
是否可以将应用程序的Info.plist
文件中的值用作Settings.bundle中项目的DefaultValue
值? 例如CFBundleVersion
。 我尝试将其输入为${CFBundleVersion}
但没有用。 我也尝试更改DefaultValue
类型,但没有成功。 有任何想法吗?
背后的原因很简单:
CFBundleVersion
在编译时是已知的,因此我不必从应用程序的mainBundle
获取其值,然后将该值应用于NSUserDefaults
。 NSUserDefaults
没有机会自行执行...所以永远记住我有手动更改“设置”捆绑包值。 这就是我同步应用程序版本以在Settings.bundle中使用的方式
[defaults setObject:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] forKey:@"kVersion"];
[defaults synchronize];
我将这段代码放在我的didFinishLaunchingWithOptions:
应用程序委托中,因此,每次应用程序启动时,请确保正确的版本显示在我的Settings.bundle中。 这将从您的info.plist中获取应用程序版本值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.