• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSMutableDictionary Q's
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableDictionary Q's


  • Subject: Re: NSMutableDictionary Q's
  • From: Mel Walker <email@hidden>
  • Date: Fri, 3 Jan 2003 19:22:52 -0700

On Friday, January 3, 2003, at 07:06 PM, email@hidden wrote:

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.[...]
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.

This is important, because if you just retain the string object, AND the string was mutable, it could change behind the scenes in another function somewhere. If you copy the string object, the value of the string will not change, since your object will own the only copy.

The "rule" as I understand it is: If you want the actual object, retain it. If you want the value of the object, copy it. As was said earlier, this is mostly applied to names or dictionary keys.

--
Mel Walker <email@hidden>
"I'm fine, but I need more funding."
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Ignoring an empty field in the address book
  • Next by Date: beginSheetForDirectory
  • Previous by thread: Re: NSMutableDictionary Q's
  • Next by thread: Re: NSMutableDictionary Q's
  • Index(es):
    • Date
    • Thread