No, you do not need to explicitly retain the NSString
, because your object already does that. Since the dictionary retains the object, the NSString
is safe from being released prematurely.
Moreover, NSDictionary
makes a copy of your string key, as a precaution against using a mutable object as a dictionary key (which is very bad). That's why you are free to change that key inside the object as you please. Of course that would not change the placement of the object inside the dictionary.