ios - Replace some contents of NSMutableDictionary with another NSMutableDictionary -
i having 2 nsmutabledictionaries each has 5 nsarrays inside,
these 2 nsmutabledictionaries have excactly same 5 keys , nsarrays different content,
i need replace 2 arrays arrays of other nsmutabledictionary
dic1 = dic2; //isn't solution...will replace contents of 1 other...
i need can replace object of specific key other same key.
i tried
[dic1 setobject:[dic2 objectforkey:@"key1"] forkey:@"key1"]; [dic1 setobject:[dic2 objectforkey:@"key2"] forkey:@"key2"];
and error: attempt insert nil value (key: key1)'
the error means [dic2 objectforkey:@"key1"]
returning nil value. in other words, key not exist in dictionary. likewise, can't set nil value inside of nsdictionary, thats why error sent out.
print out each of dictionaries , ensure keys/values expect. can use nslog or pause program breakpoint, , enter po dic1
in console.
Comments
Post a Comment