通過模態的方法把數組中的字典中的數組放到一個數組中,並可以用點語法實現調用
1.解析數據:
代碼:
NSString *path =[[NSBundle mainBundle] pathForResource:@"StudentArr" ofType:@"plist"];
self.stuArr =[NSMutableArray arrayWithContentsOfFile:path];
用self.stuArr 來接收收據,這個數組裏面全是字典
2.接下來用forin的方法快速變遍歷得到字典
代碼:
for (NSMutableDictionary *dic in self.stuArr)
3.通過KVC對model進行賦值
代碼:
Student *stu=[[Student alloc] init];
[self.stu setValuesForKeysWithDictionary:dic];
到這步結束之後,就可以實現stu的點語法調用字典中value了
4.最後把數據加到數組中,完成解析數據
代碼:
[self.arr addObject:stu];