• 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: -[NSString stringWithCString:encoding:] memory management question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -[NSString stringWithCString:encoding:] memory management question


  • Subject: Re: -[NSString stringWithCString:encoding:] memory management question
  • From: Kyle Sluder <email@hidden>
  • Date: Thu, 12 Nov 2009 09:36:39 -0800

On Nov 12, 2009, at 6:52 AM, Jeremy Pereira <email@hidden> wrote:


On 12 Nov 2009, at 14:23, Hank Heijink (Mailinglists) wrote:


Why is that? The only difference between setValue:forKey: and setObject:forKey: is that the former uses the latter unless value is nil, in which case the key will be removed. Come to think of it, using setObject:forKey: will give me the advantage of raising an exception if I try to add nil to the dictionary instead of failing silently - I think I'll switch. Thanks!

That shows that one should check the docs before saying something. I always thought setValue:forKey: was only for use with key-value coding but the docs for NSMutableDictionary seem to imply you can also use it in the more general way as you are doing.

While -setValue:forKey: will work, you are correct in saying that you should only use it for key-value coding. KVC keys must be strings, NSMutableDictionary will prefer to respond to it's own properties before checking its contents, nil is handled differently…


--Kyle Sluder_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >-[NSString stringWithCString:encoding:] memory management question (From: "Hank Heijink (Mailinglists)" <email@hidden>)
 >Re: -[NSString stringWithCString:encoding:] memory management question (From: Jeremy Pereira <email@hidden>)
 >Re: -[NSString stringWithCString:encoding:] memory management question (From: "Hank Heijink (Mailinglists)" <email@hidden>)
 >Re: -[NSString stringWithCString:encoding:] memory management question (From: Jeremy Pereira <email@hidden>)

  • Prev by Date: Re: NSXMLParser choking on single quotes
  • Next by Date: How do I get Lucida Grande italic into my application?
  • Previous by thread: Re: -[NSString stringWithCString:encoding:] memory management question
  • Next by thread: Re: -[NSString stringWithCString:encoding:] memory management question
  • Index(es):
    • Date
    • Thread