• 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: RS: What's the difference?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RS: What's the difference?


  • Subject: Re: RS: What's the difference?
  • From: Alastair Houghton <email@hidden>
  • Date: Tue, 29 May 2007 18:02:15 +0100

On 28 May 2007, at 15:42, Shawn Erickson wrote:

On May 28, 2007, at 7:04 AM, Roland Silver wrote:

What's the difference between the two NSDictionary methods valueForKey and objectForKey?

-[NSDictionary objectForKey:] is the primary way to fetch an object from an NSDictionary.


-[NSDictionary valueForKey:] implements KVC support for dictionaries (part of the NSKeyValueCoding informal protocol).

Perhaps the most important point (which I think probably is worth stating here) is that -valueForKey: will work on non-NSDictionary objects (provided they support KVO), whereas -objectForKey: generally won't. It's also worth saying that -valueForKey:'s behaviour on the collection objects is a little different to what you might naïvely expect (though it's potentially very useful).


Kind regards,

Alastair.

--
http://alastairs-place.net


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: 
 >RS: What's the difference? (From: Roland Silver <email@hidden>)
 >Re: RS: What's the difference? (From: Shawn Erickson <email@hidden>)

  • Prev by Date: Re: memory mgmt in convenience and accessor methods
  • Next by Date: Re: Can't customize toolbar in category
  • Previous by thread: Re: RS: What's the difference?
  • Next by thread: observing dealloc
  • Index(es):
    • Date
    • Thread