Re: -[NSString stringWithCString:encoding:] memory management question
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