我有两个NSMutableArray
,NSdictionary
我需要在一个中合并/合并UITableView
。任何提示或提示都将受到高度赞赏。这是我的代码的一部分。
我需要将它们合二为一tableView
,并灵活地显示所需的任何值
第一个NSMutableArray
是Dictionary
这个
{
creationTime = "/Date(1373276760000)/";
displayString = "<CA><MSG></MSG></CA>";
eventEndTime = "/Date(-62135568000000)/";
eventId = 3704408;
eventStartTime = "/Date(1373276100000)/";
eventType = 451;
instanceId = "3c9c5b4c-ae6f-4565-8f18-324c72bb532a";
instanceName = "Arrival Time";
notes = (
);
severity = 2;
},
第二个是:
{
Address = "Beverly Hill 902220";
ArrivalMonthDayText = "7/8 3:20 AM";
ArrivalTime = "/Date(1373278800000)/";
ArrivalTimeText = "7/8/2013 3:20 AM";
Caption = "2013-07-08 03:20 Unscheduled Stop";
DepartureMonthDayText = "7/8 3:45 AM";
DepartureTime = "/Date(1373280300000)/";
DepartureTimeText = "7/8/2013 3:45 AM";
DoorOpened = 0;
DoorText = Closed;
Duration = 25;
DurationText = "00:25";
Id = "c1b12403-9864-4e70-9f10-477d5cebee2c";
Label = "Unscheduled Stop";
Metrics = (
{
DeliveryMetricId = "5132ad49-55ea-4363-8920-c2ad5b1d51be";
Label = CompartmentA;
Value = "41.9";
},
{
DeliveryMetricId = "02b90c9e-73e2-4fd1-a91c-be00f4fdf4b9";
Label = CompartmentB;
Value = "11.9";
}
);
}
}
cellForRowAtIndexPath 内的测试代码:
if (tableView==tblRoute) {
if ([globEventAlert count]>0)//first source
{
int eventtype=[[[globEventAlert valueForKey:@"eventType"]objectAtIndex:indexPath.row]intValue];
if(eventtype==401 || eventtype==402)
{
[btnTblImage setImage:yellowFlag forState:UIControlStateNormal];
btnTblImage=(UIButton*)[cell viewWithTag:100];
[lblDeptTime setText:@"-"];
lblDeptTime=(UILabel *)[cell viewWithTag:103];
}
if(eventtype==410 || eventtype==412 || eventtype==413|| eventtype==420|| eventtype==422 || eventtype==423)
{
[btnTblImage setImage:missingSensor forState:UIControlStateNormal];
btnTblImage=(UIButton*)[cell viewWithTag:100];
[lblDeptTime setText:@"-"];
lblDeptTime=(UILabel *)[cell viewWithTag:103];
}
if(eventtype==411 || eventtype==414 || eventtype==421|| eventtype==424)
{
[btnTblImage setImage:spikeSensor forState:UIControlStateNormal];
btnTblImage=(UIButton*)[cell viewWithTag:100];
[lblDeptTime setText:@"-"];
lblDeptTime=(UILabel *)[cell viewWithTag:103];
}
NSString *eventTypeDescription =[TMSGlobalFunctions checkEventType:eventtype];
[lblLabel setText:eventTypeDescription];
lblLabel=(UILabel *)[cell viewWithTag:102];
NSString *startTime=[TMSGlobalFunctions strDate:[NSDate convertJSONDateToNSDate:[[globEventAlert valueForKey:@"eventStartTime"]objectAtIndex:indexPath.row]]];
[lblArrivalTime setText:startTime];
lblArrivalTime =(UILabel *)[cell viewWithTag:101];
}
if ([globStopInfo count]>0)//2nd nsmutable array of nsdictionary
{
NSString *labelStop=[NSString stringWithFormat:@"%@",[[globStopInfo objectForKey:@"Label"]objectAtIndex:indexPath.row]];
if ([labelStop isEqualToString:@"UnscheduledStop"]) {
[btnTblImage setImage:unScheduleStop forState:UIControlStateNormal];
btnTblImage=(UIButton*)[cell viewWithTag:100];
[lblDeptTime setText:@"-"];
lblDeptTime=(UILabel *)[cell viewWithTag:103];
}
[lblLabel setText:[[globStopInfo valueForKey:@"Label"]objectAtIndex:indexPath.row]];
lblLabel=(UILabel *)[cell viewWithTag:102];
NSString *startTime=[[globStopInfo valueForKey:@"ArrivalTimeText"]objectAtIndex:indexPath.row];
[lblArrivalTime setText:startTime];
lblArrivalTime =(UILabel *)[cell viewWithTag:101];
}
}
UIView *bgcolor=[[UIView alloc]init];
[bgcolor setBackgroundColor:[UIColor colorWithRed:255/255.0f green:159.0/255.0f blue:0.0/255.0f alpha:.7]];
bgcolor.layer.cornerRadius=1;
[cell setSelectedBackgroundView:bgcolor];
return cell;
}
任何想法或帮助都将受到高度赞赏。谢谢你