如何通过比较具有相同值的两个不同对象来合并2个数组?

时间:2017-12-11 16:11:04

标签: ios objective-c arrays json

我有2个阵列名为" onGoingBookings"和" sortedMSArray" 。当两个预订ID值相同时,我想将sortedMSArray(仅限状态键)注入/合并到onGoingBooings数组(主数组)。

正在进行的书籍的响应

(LocalReport)e.Report.LoadSubReportDefinition(...)

sortedMSArray的响应

{
        addrLine1 = "Al Thanyah Fifth, Dubai, United Arab Emirates";
        addrLine2 = "  ";
        amount = "";
        apntDate = "2017-12-11";
        apntDt = "2017-12-11 11:48:18";
        apntTime = "11:48 am";
        apptLat = "25.071571350098";
        apptLong = "55.14294052124";
        bid = 374;
        bookType = 1;
        cancelAmount = 30;
        "cancel_reason" = "";
        "cat_name" = "Car Wash";
        "dispute_msg" = "";
        disputed = "";
        dt = 20171211114818;
        email = "dev@ios.com";
        fdata =         {
        };
        fname = Apple;
        lname = Mob;
        notes = "";
        pPic = "https://s3.amazonaws.com/iserve/ProfileImages/dev@ios.com2017-11-2711:34:26.jpg";
        phone = 561462146;
        pid = 48;
        "star_rating" = 0;
        statCode = 6;
        status = "Job started.";
    },
        {
        addrLine1 = "Al Thanyah Fifth, Dubai, United Arab Emirates";
        addrLine2 = "  ";
        amount = "";
        apntDate = "2017-12-06";
        apntDt = "2017-12-06 19:29:14";
        apntTime = "07:29 pm";
        apptLat = "25.071369171143";
        apptLong = "55.143840789795";
        bid = 354;
        bookType = 2;
        cancelAmount = 50;
        "cancel_reason" = "";
        "cat_name" = Plumbing;
        "dispute_msg" = "";
        disputed = "";
        dt = 20171206192914;
        email = "";
        fdata =         {
        };
        fname = "";
        lname = "";
        notes = "";
        pPic = "";
        phone = "";
        pid = "";
        "star_rating" = 0;
        statCode = 1;
        status = "Job Pending";
    },
        {
        addrLine1 = "Al Thanyah Fifth, Dubai, United Arab Emirates";
        addrLine2 = "  ";
        amount = "";
        apntDate = "2017-12-06";
        apntDt = "2017-12-06 19:24:12";
        apntTime = "07:24 pm";
        apptLat = "25.071369171143";
        apptLong = "55.143840789795";
        bid = 353;
        bookType = 1;
        cancelAmount = 30;
        "cancel_reason" = "";
        "cat_name" = "Car Wash";
        "dispute_msg" = "";
        disputed = "";
        dt = 20171206192412;
        email = "";
        fdata =         {
        };
        fname = "";
        lname = "";
        notes = "";
        pPic = "";
        phone = "";
        pid = "";
        "star_rating" = 0;
        statCode = 1;
        status = "Job Pending";
    },

我需要以下解决方案

第1步 - 使用@" bid"(进行中的预订)和@" bookingid"(sortedMSArray)比较两个数组 第2步 - 当两个预订ID相同时合并状态键。

请根据我的代码和回复发布剪切代码。

参考代码

 {
        bookingid = 325;
        status = 1;
    },
        {
        bookingid = 333;
        status = 3;
    },
        {
        bookingid = 374;
        status = 3;
    }

0 个答案:

没有答案