Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9183989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:56:12+00:00 2026-06-17T18:56:12+00:00

I have an NSMutableArray of NSDictionary s something like this: myArray ( { chatins

  • 0

I have an NSMutableArray of NSDictionarys something like this:

myArray (
    {
    chatins = 20;
    placeImageString = 244211112265925;
},
    {
    chatins = 5;
    placeImageString = 154909144575109;
},
    {
    chatins = 30;
    placeImageString = 193867280641162;
},
    {
    chatins = 13;
    placeImageString = 224627130902;
},

)

and another NSMutableArray of NSDictionarys something like this:

myArray2 
(
    {
    category = "Local business";
    distance = "0.1";
    name = "Mts India";
    placeImageString = 244211112265925;
},
    {
    category = "Local business";
    distance = "0.17";
    name = "Aegis Ltd";
    placeImageString = 154909144575109;
},
    {
    category = "Automobiles and parts";
    distance = "0.19";
    name = Autopsyche;
    placeImageString = 78480207511;
},
    {
    category = Company;
    distance = "0.19";
    name = "The Oberoi, Gurgaon";
    placeImageString = 121676041233945;
},

)

I want to merge myArray and myArray2 in order to get resulted NSMutableArray of NSDictionarys something like below where my placeImageString is the key to match the data in both arrays of dictionaries and if the key not found in myArray2 then the value of chatins key should be 0.

myArray3 
(
{
category = "Local business";
distance = "0.1";
name = "Mts India";
placeImageString = 244211112265925;
 chatins = 20;

},
{
category = "Local business";
distance = "0.17";
name = "Aegis Ltd";
placeImageString = 154909144575109;
chatins = 5;

},
{
category = "Automobiles and parts";
distance = "0.19";
name = Autopsyche;
placeImageString = 78480207511;
chatins = 0;


},
    {
    category = Company;
    distance = "0.19";
    name = "The Oberoi, Gurgaon";
    placeImageString = 121676041233945;
    chatins = 0;

    },
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:56:13+00:00Added an answer on June 17, 2026 at 6:56 pm

    Here I have a sample code for you:

      NSMutableArray *array1 = [[NSMutableArray alloc] init];
      NSMutableArray *array2 = [[NSMutableArray alloc] init];
    
    
      NSMutableDictionary * dict = [[NSMutableDictionary alloc]
                                    initWithObjects:[NSArray arrayWithObjects:@"1",@"ABC", nil]
                                    forKeys:[NSArray arrayWithObjects:@"ID",@"NAME", nil]];
      [array1 addObject:dict];
    
      dict = nil;
    
      /*
       Same way added 2 more dictionaries to the same array - array1
       */
    
      NSLog(@"array1: %@", array1);
    
    
      dict = nil;
    
      dict = [[NSMutableDictionary alloc]
              initWithObjects:[NSArray arrayWithObjects:@"1",@"DEF", nil]
              forKeys:[NSArray arrayWithObjects:@"ID",@"ADDRESS", nil]];
    
      [array2 addObject:dict];
    
      dict = nil;
    
      /*
       Same way added 2 more dictionaries to the same array - array2
       */
    
    
      NSLog(@"array2: %@", array2);
    
    
      for (int index = 0; index < [array1 count]; index ++) {
    
        NSMutableDictionary *dict1 = [array1 objectAtIndex:index];
    
        for (NSMutableDictionary *dict2 in array2) {
    
          if ([[dict1 objectForKey:@"ID"] isEqualToString:
               [dict2 objectForKey:@"ID"]]) {
    
            [dict1 setObject:[dict2 objectForKey:@"ADDRESS"] forKey:@"ADDRESS"];
          }
        }
      }
    

    Now at the end if you check with array1, there is one more key (ADDRESS) added in all those dictionary.

    Hope this help.

    -Mrunal

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like this: @interface Person : NSObject { NSString *fname; NSString *lname;
I have an NSMutableArray full of NSDictionary objects. Like so NSMutableArray *names = [[NSMutableArray
I have tried this but it crashes: - (NSDictionary *)contacts { NSMutableArray *result =
i have another problem this time, i'm fetching json codes that will be used
i have an XML file as url where the file contains like this, <Products>
I have NSDictionaries stored in an NSMutableArray. Each NSDictionary has a NSNumber inside of
I have a NSMutableArray property in my AppDelegate called blocks. I would like to
Hihi all, I have an NSMutableArray containing various NSDictionary. In each of the NSDictionary,
In my app, I have a dictionary with two array like: NSDictionary *d=[[NSDictionary alloc]initWithObjectsAndKeys:listOfEvents,@l,arr_distance,@d,
I have a plist like this: <dict> <key>New item</key> <dict> <key>document</key> <string>driving licence</string> <key>Overview</key>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.