On Nov 10, 2015, at 10:52 , Alex Zavatone <z...@mac.com> 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 to agonize over this. ‘objectForKey’ is the correct 
method to use. That is to say, if your code is working with a variable of type 
NSDictionary or NSMutableDictionary, the NSDictionary API is the correct one to 
use. There’s absolutely no need to take a detour via KVC.

Similarly, you should remove the try/catch blocks, if they do nothing but trap 
the case where there is no object for the given key. In that situation, the nil 
return is mandatory for the implementation. Any other exceptions should be 
uncaught, and allowed to crash the app, according to current best practices.

Note that there may be an interesting-to-some discussion over whether and how 
NSDictionary’s interpretation of KVC's ‘valueForKey’ happens to overlap in 
functionality with NSDictionary’s ‘objectForKey’. Continue that discussion if 
you like, but use ‘objectForKey’ anyway.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to