Objective-C: copying specific NSDictionary Values into another NSDictionary
-
03-07-2021 - |
Question
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
Solution
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;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow