I have a nsmutabledictionnary, and when I use setObject:forKey: with a nsstring key it works when I try objectForKey, but if I put a nsmutablestring in the key argument of the SetObject:forKey: method, it’s not work when I call objectForKey, it return the last object in the dictionnary…
I have a nsmutabledictionnary, and when I use setObject:forKey: with a nsstring key it
Share
You should know that NSDictionary (and NSMutableDictionary) copies the key before adding it – thus, if you use a NSMutableString as a key, then modify that same string, the key in the database will still have the old value. This is done for a reason – the key in a NSDictionary should always be static, since it’s actually the hash of it that’s used for retrieving the associated value.