Martin
Martin

Reputation: 800

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. 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, martin

Upvotes: 0

Views: 1022

Answers (1)

totallhellfail
totallhellfail

Reputation: 70

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];

Upvotes: 3

Related Questions