Objective-C, particularly after it became 2.0, is my favourite language. It’s partly
because of the language itself, but I guess mostly because of the libraries. The Cocoa
libraries are awesome.
For the most part. No software is perfect, and even in Cocoa there are things that could
be improved. One thing that continue to trip me up is one of
dictionaryWithObjectsAndKeys: always end up confusing me, as the
arguments always seem in the wrong order. It would make much more sense to
have the method
dictionaryWithKeysAndObjects: where you
specified a list of key/value pairs, rather than value/key pairs.
Here’s a random sample of the above from the Adium
source code. Honestly. I grabbed the first sample from it I could find. I did not hunt for
a particularly egregious example:
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
Doesn’t that make a lot more sense like this?
NSDictionary *userInfo = [NSDictionary dictionaryWithKeysAndObjects:
This has confused me so many times now that I have filed a feature request with Apple
(<rdar://problem/6171269>) to have a new method with the arguments in the “right” order.
(Wondering if that url is broken? Read about rdar
work for Apple.) Here’s to hoping that they honour it and put it in Snow Leopard…