简体   繁体   English

无法从资源读取plist

[英]can't read plist from resources

in my resources directory i have a file called lsf.plist i want to load this file (dictionary) but i always get null as content of the file. 在我的资源目录中,我有一个名为lsf.plist的文件,我想加载该文件(字典),但我总是将null作为文件的内容。 i am using the following code. 我正在使用以下代码。 i've verified that the file is in the app after the build. 我已验证该文件在构建后已在应用程序中。

self.path = [[NSBundle mainBundle] pathForResource:@"lsf" ofType:@"plist"]; 
NSLog(self.path);
self.lsf = [NSMutableArray arrayWithContentsOfFile:path];
NSLog(@"%@",lsf);

The first log-output shows the path and the second one gives me null.... it would be great if you can help me to solve this issue! 第一个日志输出显示路径,第二个日志输出显示路径为null。...如果您可以帮助我解决此问题,那就太好了!

Br, martin 马丁

Is root of your plist array or dictionary? 是plist数组或字典的根吗? Also you dont need to use self. 另外,您不需要使用自我。 Heres an example from a project of mine: 以下是我的一个项目示例:

NSString* path = [[NSBundle mainBundle] pathForResource:@"property" ofType:@"plist"];
NSDictionary *newDict = [NSDictionary dictionaryWithContentsOfFile:path];

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

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