• 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
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]

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


  • Subject: The joys of people using valueForKey to get objects out of a dictionary.
  • From: Alex Zavatone <email@hidden>
  • Date: Tue, 10 Nov 2015 11:32:51 -0500
  • X_v_e_cd: 514e1db90a4f165843f9e7f1711b17df
  • X_v_r_cd: 1b72e56d73b7d2470dc574b4a0f4d683

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?

Looking for reasons why I can explain "yeah, I know it works, but here's why it's a terrible idea to use to access a dictionary's objects".

Thanks in advance.
_______________________________________________

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


  • Follow-Ups:
    • Re: The joys of people using valueForKey to get objects out of a dictionary.
      • From: Greg Parker <email@hidden>
    • Re: The joys of people using valueForKey to get objects out of a dictionary.
      • From: David Duncan <email@hidden>
    • Re: The joys of people using valueForKey to get objects out of a dictionary.
      • From: "Clark S. Cox III" <email@hidden>
    • Re: The joys of people using valueForKey to get objects out of a dictionary.
      • From: Jens Alfke <email@hidden>
    • Re: The joys of people using valueForKey to get objects out of a dictionary.
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: UINavigationController, hidesBarsWhenVerticallyCompact, and "unhandled taps" - how to "handle" them
  • Next by Date: Re: The joys of people using valueForKey to get objects out of a dictionary.
  • Previous by thread: Re: UINavigationController, hidesBarsWhenVerticallyCompact, and "unhandled taps" - how to "handle" them
  • Next by thread: Re: The joys of people using valueForKey to get objects out of a dictionary.
  • Index(es):
    • Date
    • Thread