Skip navigation.
 
mlRe: NSMutableDictionary Q's
FROM : Dietrich Epp
DATE : Fri Jan 03 23:56:29 2003

On Thursday, January 2, 2003, at 04:57 , Jonathan E. Jackel wrote:

>> In addition, you probably shouldn't be retaining the NSStrings passed
>> to
>> the set... methods.  You should be copying them, or at least in the
>> case
>> of setName.

>
> Huh?
>
> Accessors in the code I have seen (and written) retain strings in
> setters
> without any problem at all.


I think this should just be for the name, actually.

> I'm going out on a wee bit of a limb because I haven't seen the source
> code
> for NSString, but . . . the NSCopying protocol (to which NSString
> conforms)
> strongly implies that a nonmutable string that is sent a "copy" message
> is
> simply retained.  The object that made the copy owns the copy and has to
> release the copy -- exactly as if the object had just retained the
> string.
>
> There's no difference.  Is there?


There is if it's passed a NSMutableString.  The dictionary will not
retain keys, it will copy them.  This string is being used as a key, I
would copy it if I were programming it.
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
mlNSMutableDictionary Q's Mike McCune Jan 2, 23:12
mlRe: NSMutableDictionary Q's Dietrich Epp Jan 3, 01:05
mlRE: NSMutableDictionary Q's Jonathan E. Jackel Jan 3, 01:57
mlRe: NSMutableDictionary Q's Dietrich Epp Jan 3, 23:56
mlRe: NSMutableDictionary Q's Mel Walker Jan 4, 03:22
mlRe: NSMutableDictionary Q's Mike McCune Jan 7, 06:07
mlRe: NSMutableDictionary Q's Andrew Thompson Jan 7, 06:57