iPhone:与NSDictionaries合作

时间:2011-08-17 15:28:51

标签: iphone

我有一个pList,其中我有5个Dictionary项。我正在尝试将这个词典读成数组

NSString *plistPath = 
    [[NSBundle mainBundle] pathForResource:@"pListName" ofType:@"plist"];
NSArray *myArray = [NSArray dictionaryWithContentsOfFile:plistPath];
NSLog(@"%d", myArray.count);

但“myArray”一直都是空的......我做错了什么?提前谢谢......

1 个答案:

答案 0 :(得分:2)

NSArray *myArray = [NSArray dictionaryWithContentsOfFile:plistPath];

应该是:

NSArray *myArray = [NSArray arrayWithContentsOfFile:plistPath];

myArray.count 

应该是[myArray count](正如乔提到的那样)