iOSDeveloper
iOSDeveloper

Reputation: 461

Relating Two Different NSDictionaries using keys

suppose If i have two NSDictionaries with same keys but different values. i need to find the value of the Dictionary 2 using Dictionary 1’s key.

example

MYDictionaryONE
{
58937 =     {
        Changed = NO;
        ChangedColorCode = Nil;
            };
58859 =     {
        Changed = NO;
        ChangedColorCode = Nil;

    };
}


MYDictionaryTWO
{
58937 =     {
        pass = YES;
        Fail=Nil;
            };
58859 =     {
        pass = YES;
        Fail = Nil;

    };
}

I just want to take one key at a time from MYDictionaryONE and search the value related to that key in MYDictionaryTWO. I tried storing all keys but i missed the logic

Upvotes: 0

Views: 34

Answers (1)

Vishal Singh
Vishal Singh

Reputation: 4480

Try below snippet.

 NSArray *allKeys = [MYDictionaryONE allKeys];

    for(int i = 0; i < allKeys.count; i++)
    {
          NSString *key = allKeys[i];
          id object = MYDictionaryTWO[key];

    }

Upvotes: 1

Related Questions