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
> On 10 Nov 2015, at 16:32, Alex Zavatone 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
> On Nov 10, 2015, at 8:32 AM, Alex Zavatone wrote:
>
> 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".
I don’t know any reason why it would be bad, although I don’t typically use it.
On Nov 10, 2015, at 10:52 , Alex Zavatone wrote:
>
> For what we're doing on a daily basis, if we're not using @ within our keys,
> I still can't see anything concrete besides "objectForKey is an NSDictionary
> method" while "valueForKey is a KVO method".
You don’t really have
> 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"™,
I would like to see these
> On Nov 10, 2015, at 8:32 AM, Alex Zavatone 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
> On Nov 10, 2015, at 10:52 AM, Alex Zavatone wrote:
>
> Here's a great reason to use objectForKey: wherever possible instead of
> valueForKey: - valueForKey: with an unknown key will throw
> NSUnknownKeyException saying "this class is not key value coding-compliant
> for the
And you guys have no idea how useful this discussion was to me today.
Even though the KVO valueForKey: method doesn't crater with an
NSUnknownException with ease, it turns out that this wonderful code is also
using the KVO method of setValue: forKey: on a dictionary.
And guess what?
***
Lots of stuff with that. An immutable dictionary can't be changed. Someone
doesn't know how to spell unknown (NSUnknosnKeyException). And not sure if that
period is part of the key username or just good English, but if given as part
of the key, it becomes a key path with an empty key. Anyway,
On Nov 10, 2015, at 2:15 PM, Jens Alfke wrote:
>
>> On Nov 10, 2015, at 10:52 AM, Alex Zavatone wrote:
>>
>> Here's a great reason to use objectForKey: wherever possible instead of
>> valueForKey: - valueForKey: with an unknown key will throw
>> NSUnknownKeyException saying
> Le 10 nov. 2015 à 19:52, Alex Zavatone a écrit :
>
>
> On Nov 10, 2015, at 12:35 PM, Greg Weston 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
>>>
> On Nov 10, 2015, at 15:21, Alex Zavatone wrote:
>
>
>> Yeah. Honestly, I'm looking for cases that would justify why all the
>> dictionary object access blocks in this code that use valueForKey are
>> wrapped with @try/@catch clauses. I've never seen cases with objectForKey
12 matches
Mail list logo