开发者

can't read plist from resources

开发者 https://www.devze.com 2023-01-13 17:23 出处:网络
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. i am using the following code. i\'ve verified that the fil

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. 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!

Br, m开发者_开发技巧artin


Is root of your plist array or dictionary? 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];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号