2012-04-05 57 views
0

在文件中有9个字典,每个字典都有两个密钥。我想获得dictionary.I数组获取数组元素是:0 这是代码:提前为什么不算数组元素?

NSString * path = [[NSBundle mainBundle]pathForResource:@"List" ofType: @"plist"]; 

NSArray *array = [NSArray arrayWithContentsOfFile:path]; 

感谢

+0

请确认您的路径有效(而不是零),并在xcode中显示您plist的内容。 – borrrden 2012-04-05 06:36:42

+0

Pl。检查链接并评论你的问题是否已经解决。 – Ilanchezhian 2012-04-05 06:38:15

回答

0
NSString *file = [[NSBundle mainBundle] pathForResource:@"List" ofType:@"plist"]; 
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:file]; 
NSArray *array = [dict objectForKey:@"Array"]; 

希望这有助于

你的plist是字典不是数组。所以检查一下。

+0

谢谢,我错了plist的根源。我写而不是。非常感谢你 – 2012-04-05 07:21:04

+0

雅..这只是一个例子。接受它,如果这有助于你。 – DivineDesert 2012-04-05 08:01:22

相关问题