I try to put a plist file content into an array using this functions :
NSString *path = [[NSBundle mainBundle] pathForResource:@"DataFile" ofType:@"plist"];
self.contentData = [NSArray arrayWithContentsOfFile:path];
But self.contentData keeps being null... I don't understand why. I use开发者_如何转开发d the same code than the one shown in the Apple "PageControl" sample project (See here), using also a pList file with the same structure (list of Dictionary items with 2 strings inside).
path is filled with : /var/Mobile/Applications/somehexvalues/MyApp.app/DataFile.plist
How could I know what is going wrong ?
NSLog(@"%@", [NSDictionary dictionaryWithContentsOfFile:path]); gives :
"Item 0" = {
imageKey = "hearts.png";
nameKey = Hearts;
};
"Item 1" = {
imageKey = "leef.png";
nameKey = Leef;
};
"Item 2" = {
imageKey = "round.png";
nameKey = Round;
};
Your PLIST has an NSDitionary instead of an NSArray, that is why you get null. If you try to load an NSArray into a NSDcitionary, you will get null as well.
精彩评论