title: iOS How to merge two NSArrays and remove Duplicates based on Unique ID in swift?
body: <p>In My Project I want to Merge two arrays and Remove the duplicates based on Unique ID and add the missing objects from second array as a child array of the merged array in swift?</p>
  
  <p>Here I give the First NSArray:</p>
  
  <pre><code>[{
      AccountNumber = 134679852;
      AssessmentRollId = 12;
      AssessmentYear = 1995;
      City = houston;
      DateCreated = "2018-01-22T18:43:53.6";
      DateModified = "2018-01-22T18:43:53.603";
      FIPS = 40125;
      Id = 1223;
      LandUseCode = 40125;
      LotSizeSquareFeet = 45;
      PropertyId = 3177;
  },
      {
      AccountNumber = 134679852;
      AssessmentRollId = 12;
      AssessmentYear = 1995;
      City = houston;
      DateCreated = "2018-01-22T18:47:23.94";
      DateModified = "2018-01-22T18:47:23.943";
      FIPS = 40125;
      Id = 1224;
      LandUseCode = 40125;
      LotSizeSquareFeet = 45;
      PropertyId = 3177;
  }]
  </code></pre>
  
  <p>This is the second Array:</p>
  
  <pre><code>[{
      AccountNumber = 547427;
      City = "Berlin";
      FIPS = 48453;
      InspectionId = 143;
      InspectionLogId = 90;
      InspectionType = "Property Owner";
      InspectionTypeId = 1;
      ScheduledDate = "2018-01-22T00:00:00";
      TemplateId = 1110;
      TemplateName = "Beta validation Jennish";
      UserId = 3177;
      UserPropertyId = 1225;
  },
      {
      AccountNumber = R157509;
      City = "Santa Fe";
      FIPS = 48167;
      InspectionId = 144;
      InspectionLogId = 91;
      InspectionType = "Property Owner";
      InspectionTypeId = 1;
      ScheduledDate = "2018-01-22T00:00:00";
      TemplateId = 1111;
      TemplateName = "beta validation 3";
      UserId = 3177;
      UserPropertyId = 1226;
  }]
  </code></pre>
  
  <p>Please Help me for find the solution, I am little bit weak in Technical Knowledge Because now only I am learning..</p>
  
  <p>I want to make this type parent child format:</p>
  
  <pre><code>[{
      AccountNumber = 134679852;
      AssessmentRollId = 12;
      AssessmentYear = 1995;
      City = houston;
      DateCreated = "2018-01-22T18:43:53.6";
      DateModified = "2018-01-22T18:43:53.603";
      FIPS = 40125;
      Id = 1223;
      LandUseCode = 40125;
      LotSizeSquareFeet = 45;
      PropertyId = 3177;
      InspectionDetails:{
              InspectionId = 143;
              InspectionLogId = 90;
              InspectionType = "Property Owner";
              InspectionTypeId = 1;
              ScheduledDate = "2018-01-22T00:00:00";
              TemplateId = 1110;
              TemplateName = "Beta validation Jennish";
              UserId = 3177;
              UserPropertyId = 1225;
      }
  }]
  </code></pre>
  
  <p>This is I tried to Remove Duplicates Using Set..</p>
  
  <pre><code>let mergedArray:NSArray = Array1.addingObjects(from: Array2 as! [Any]) as NSArray
              let mySet = NSSet(array : mergedArray as! [Any])
              let uniquArray:NSArray = mySet.allObjects as NSArray
  </code></pre>