Ever since I started coding in Cocoa, I’ve been wondering what might be the longest name used for any function or constant in the entire API. Cocoa names can get quite long in general, so the longest one should be really ridiculously long… Of course I couldn’t leave it like this and I had to find out what it was :)
I ran a search for *.h files on the whole disk, and I determined that the interesting stuff was either in /Developer or in /System/Library/Frameworks, so I limited the search to these directories only. I passed the list of all header files through a Ruby script that looked for the really long ones and sorted them by length, and then I analyzed the results to find the winners (I decided to divide them into a few categories).
So here’s what I’ve found:
The longest name in the whole result set
face_ create_ for_ atsu_ font_ id_ REPLACED_BY_ cairo_ quartz_ font_ face_ create_ for_ atsu_font_id
This monstrosity was found in cairo-deprecated.h in X11 headers directory. Doesn’t really count as Cocoa though, it wasn’t even written by Apple (it says RedHat in the comments).
The longest names in Apple’s frameworks:
Create Physical Link Response AMP Disconnected Physical Link RequestReceived
Inquiry Response Data Type128Bit Service Class UUIDs With MoreAvailable
These were both found inside IOBluetooth.framework. Note to self: don’t try to code anything Bluetooth-related in Cocoa…
VERSION_10_0_AND_LATER_ BUT_ DEPRECATED_ IN_ MAC_OS_X_VERSION_10_5
This award goes to this interesting macro and all its relatives, of which there are many (basically all possible combinations of existing MacOSX versions). These things are just *everywhere*… For the rest of the categories I’m going to ignore these, to make the results more interesting.
The longest names in Cocoa:
It’s hard to tell what exactly counts as Cocoa and what doesn’t, I’ve always thought of Cocoa as a broad term including all of Apple’s MacOSX frameworks. However, if you import
<Cocoa/Cocoa.h> in your code, it only includes Foundation, AppKit and CoreData, so I guess technically only these three form the core Cocoa framework.
Here are the winners in this category:
Layout Point For Screen Point Parameterized Attribute
Screen Point For Layout Point Parameterized Attribute
String Enumeration Longest Effective Range NotRequired
The first two are from NSAccessibility (AppKit), the third one from NSAttributedString (Foundation).
The longest names in UIKit:
For Delete Confirmation Button For Row At IndexPath
This one is defined in the header for UITableView, but it doesn’t appear in any official documentation, so it probably shouldn’t count.
Second Half Of Rotation From InterfaceOrientation
Will Change Status Bar OrientationNotification
These two come from UIViewController and UIApplication, and they do appear in the docs.
The longest notification name:
Connection Format Description Will ChangeNotification
Controller Now Playing Item Did ChangeNotification
Notification names tend to be very long in general, so I thought they deserved their own category. These two come from QTKit and iPhone’s MediaPlayer framework. These two frameworks (and media-related frameworks in general) had a lot of crazy entries in the result list, so I guess they must be not too fun to use…
And the longest notification in Cocoa (AppKit) was this one (from NSTextInputContext.h):
Context Keyboard Selection Did ChangeNotification
So, mystery solved :) Now I can happily go back to Cocoa coding, looking at the names in my code, and knowing it’s not the worst that could have happened…