Taskinul Haque
Taskinul Haque

Reputation: 724

Objective-C: copying specific NSDictionary Values into another NSDictionary

I have a dictionary networks, which is a Dictionary of dictionaries
I'm trying to copy specific entries from networks into compare Addr

- ( NSDictionary * ) compareAddr
{
    NSMutableDictionary *result = [[NSMutableDictionary alloc] init];

    for (id key in networks)
    {
        NSMutableDictionary *result = [[NSMutableDictionary alloc] initWithObjectsAndKeys: @\    [[networks objectForKey: key] objectForKey:@"RSSI"]\, @\key\];
    }                                
    return [NSDictionary ? ? ? :result];
}

But this isn't working for me !

Is it possible ? : what am i doing wrong ?

Thanks for any and all help

Upvotes: 1

Views: 716

Answers (1)

aleroot
aleroot

Reputation: 72636

From what i can understand from your question, I think that you only need to insert in the result array the desired extracted object and key in this way :

- ( NSDictionary * ) compareAddr
{
    NSMutableDictionary *result = [[NSMutableDictionary alloc] init];

    for (id key in networks)
    {
        [result setObject:[[networks objectForKey: key] objectForKey:@"RSSI"]  forKey:key];
    }                                
    return result;
}

Upvotes: 2

Related Questions