如何打印ActivityName&描述
我有这种类型的场景作为响应,我需要解析这些数据并打印ActivityId、ActivityName&描述
Project List Array Activites List:= Array
(
(
{
ActivityID = 4;
ActivityName = Development;
Description = Development;
IsActive = 1;
},
),
)
您可以为每个循环使用两个
让projectListArray
是你的第一个数组,projectList
是里面的每个数组,projectDict
是里面的每一个字典
for (NSArray *projectList in projectListArray) {
for (NSDictionary *projectDict in projectList) {
NSLog(@"Activity ID = %d",[projectDict objectForKey:@"ActivityID"]);
NSLog(@"Activity Name = %d",[projectDict objectForKey:@"ActivityName"]);
NSLog(@"Description = %d",[projectDict objectForKey:@"Description"]);
}
}
首先将Plist获取到数组
NSString *stringPath = [[NSBundle mainBundle]pathForResource:@"yourPlistName" ofType:@"plist"];
NSMutableArray *arrPlist = [NSMutableArray arrayWithContentsOfFile:stringPath];
然后从阵列中获取数据
for(int i=0;i<arrPlist.count;i++)
{
NSString *strID = [NSString stringWithFormmat:@"%@",[arrPlist objectAtIndex:i]objectForKey:@"ActivityID"]];
NSString *strName = [NSString stringWithFormmat:@"%@",[arrPlist objectAtIndex:i]objectForKey:@"ActivityName"]];
NSString *strDesc = [NSString stringWithFormmat:@"%@",[arrPlist objectAtIndex:i]objectForKey:@"Description"]];
}