简体   繁体   English

iOS - 获取Info.plist文件

[英]iOS - Get Info.plist file

I have a method that loads data from the Info.plist file of an app. 我有一个方法从应用程序的Info.plist文件加载数据。 Right now I'm hardcoding the name and the type, ie using pathForResource however, this approach fails if the name of the plist file has changed, say MyAppSettings.plist Is there a way I can get the info.plist file that is being used regardless of the name? 现在我正在硬编码名称和类型,即使用pathForResource但是,如果plist文件的名称已经改变,这种方法会失败,比如MyAppSettings.plist有没有办法可以获得正在使用的info.plist文件不管名字? Thanks 谢谢

The main App settings file, mostly named MyApp-info.plist , will al ways be named info.plist after the app is compiled and bundled. 应用程序编译和捆绑后,主要的应用程序设置文件(主要名为MyApp-info.plist )将命名为info.plist

There is also a short way to acces the info.plist : 还有一个访问info.plist的简短方法:

NSNumber *version =  [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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