合并nsdictionary的两个nsmutablearray的值作为UITableView的值

时间:2013-07-08 11:41:16

标签: ios uitableview merge nsmutabledictionary

我有两个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;    
}

非常感谢任何想法或帮助。谢谢

0 个答案:

没有答案