• 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: The joys of people using valueForKey to get objects out of a dictionary.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The joys of people using valueForKey to get objects out of a dictionary.


  • Subject: Re: The joys of people using valueForKey to get objects out of a dictionary.
  • From: Mike Abdullah <email@hidden>
  • Date: Tue, 10 Nov 2015 16:35:28 +0000
  • X_v_e_cd: a14aaa13d59e27537b952689840d5a0b
  • X_v_r_cd: c6a5fb8a1d3f1f2d659ba0dc737a5527

> On 10 Nov 2015, at 16:32, Alex Zavatone <email@hidden> wrote:
>
> It's been about 4 or 5 years since I made this mistake but I've just seen a massive swath of code where every access of a dictionary object is using valueForKey instead of objectForKey.
>
> I've got a few examples of why this is a "really bad idea"™, and certainly might explain why lots of that code is wrapped in try/catch blocks.
>
> Am I correct that using valueForKey will raise an exception if the key is missing?

Nope, it’ll cheerfully return nil.


_______________________________________________

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: 
 >The joys of people using valueForKey to get objects out of a dictionary. (From: Alex Zavatone <email@hidden>)

  • Prev by Date: The joys of people using valueForKey to get objects out of a dictionary.
  • Next by Date: Re: The joys of people using valueForKey to get objects out of a dictionary.
  • Previous by thread: The joys of people using valueForKey to get objects out of a dictionary.
  • Next by thread: Re: The joys of people using valueForKey to get objects out of a dictionary.
  • Index(es):
    • Date
    • Thread