Reputation: 125
i am having 2 NSMutableDictionaries that each has 5 NSArrays inside,
these 2 NSMutableDictionaries have excactly the same 5 keys and NSArrays but with different content,
i need to replace only 2 Arrays with the Arrays of the other NSMutableDictionary so
dic1 = dic2; //isn't a solution...will replace all the contents of the one to the other...
i need something that can replace the object of a specific key with the other same key.
i tried
[dic1 setObject:[dic2 objectForKey:@"key1"] forKey:@"key1"];
[dic1 setObject:[dic2 objectForKey:@"key2"] forKey:@"key2"];
and i get ERROR: attempt to insert nil value (key: key1)'
Upvotes: 0
Views: 50
Reputation: 13549
The error just means [dic2 objectForKey:@"key1"]
is returning a nil value. In other words, that key does not exist in the dictionary. Likewise, you can't set a nil value inside of an NSDictionary, so thats why the error is sent out.
Print out each of the dictionaries and ensure your keys/values are what you expect. You can use an NSLog or just pause the program with a breakpoint, and enter po dic1
in the console.
Upvotes: 1