从plist中的另一个字典访问字典键

时间:2016-07-22 08:47:02

标签: ios objective-c dictionary plist info.plist

enter image description here plist of Dealers and Cars

我希望能够访问plist

中的经销商名称
- (void)viewDidLoad {
[super viewDidLoad];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Cars" ofType:@"plist"];

NSArray *array = [NSArray arrayWithContentsOfFile:filePath];
NSMutableArray *dealers = [[NSMutableArray alloc] init];
for (NSDictionary *object in array) {
    Dealer *dealer = [[Dealer alloc] initWithDictionary:object];
    [dealers addObject:dealer];
}
self.dealers = dealers;

从这里,我只访问plist

中的第一个字典

2 个答案:

答案 0 :(得分:0)

你plist中的第一个NSDictinonary具有存储经销商Item 0的{​​{1}}密钥。更改字符串代码

NSDictinonary

到这个

 Dealer *dealer = [[Dealer alloc] initWithDictionary:object];

答案 1 :(得分:-1)

我建议你检查variables-array,object