I have an NSMutableDictionary with a dozen keys, each key refers to an NSString value. If I call [myDictionary valueForKey:@"abc"] I will get an NSString object.
Is this NSString copied?
As there is no @property declaration, what happens with this retrieval of the string? I assume I get a copy. Is it any different with a NSMutableString?
My purpose is that I have an array of NSDictionaries. I call valueForKey on the array to get all the @"abc" keys from the collection of dictionaries. Thus I now have an array of NSStrings.
I need to pass that array to an NSOperation on a background thread. Thus, the NSStrings need to be copies so that modifying the dictionaries later will not cause the ones passed to the NSOperation to get changed.
From the documentation of
-[NSDictionary valueForKey:]:From the documentation of
-[NSMutableDictionary setObject:forKey:]:valueForKey:doesobjectForKey:and does not copy the object.setObject:forKey:replaces the object, it does not modify the object. If you donow
ais the old value@"klm".