Re: The joys of people using valueForKey to get objects out of a dictionary.
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: "Clark S. Cox III" <email@hidden>
- Date: Tue, 10 Nov 2015 09:04:20 -0800
> On 2015/11/10, at 8: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?
No; it returns nil.
> 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
--
Clark Smith Cox III
email@hidden
_______________________________________________
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