如何打印ActivityName&说明
我有这种情况作为回应我需要解析这些数据并打印ActivityId,ActivityName&描述
Project List Array Activites List:= Array
(
(
{
ActivityID = 4;
ActivityName = Development;
Description = Development;
IsActive = 1;
},
),
)
答案 0 :(得分:0)
你可以为每个循环使用两个
让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"]);
}
}
答案 1 :(得分:0)
首先获取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"]];
}