Cocoaで最も名前が長いメソッドベスト10

ここのところObjective-Cを勉強中なんですが、まず最初にびっくりしたのがメソッド名の長さです。

Objective-Cでは、メソッドの呼び出し時に引数の名前を明示するので、「このメソッドの2番目の引数は何の意味だっけ?」などと悩む必要がなくなる反面、メソッド名が「動詞+前置詞+名詞1:名詞2:名詞3...」のような構成になって、ものすごく長くなります。

一番長いメソッドは何文字あるのか好奇心が湧いてきたので、Cocoaのリファレンスに載っているクラスを対象に調べてみました。

まず、メソッド全体の長さベスト10です。

第1位

initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:
samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:
bytesPerRow:bitsPerPixel:
文字数: 148
所属クラス: NSBitmapImageRep

※あまりに長いので改行してますが、"initWithBitmapDataPlanes:"から"bitsPerPixel:"までが1つのメソッドです。以降も同様です。

第2位

getLineFragmentRect:usedRect:remainingRect:forStartingGlyphAtIndex:
proposedRect:lineSpacing:paragraphSpacingBefore:paragraphSpacingAfter:
文字数: 137
所属クラス: NSTypesetter

第3位

initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:
samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel:
文字数: 135
所属クラス: NSBitmapImageRep

第4位

keyEventWithType:location:modifierFlags:timestamp:windowNumber:
context:characters:charactersIgnoringModifiers:isARepeat:keyCode:
文字数: 128
所属クラス: NSEvent

第5位

drawStrikethroughForGlyphRange:strikethroughType:baselineOffset:
lineFragmentRect:lineFragmentGlyphRange:containerOrigin:
文字数: 120
所属クラス: NSLayoutManager

第6位

decimalNumberHandlerWithRoundingMode:scale:raiseOnExactness:
raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:
文字数: 113
所属クラス: NSDecimalNumberHandler

enterExitEventWithType:location:modifierFlags:timestamp:
windowNumber:context:eventNumber:trackingNumber:userData:
文字数: 113
所属クラス: NSEvent

第8位

drawUnderlineForGlyphRange:underlineType:baselineOffset:
lineFragmentRect:lineFragmentGlyphRange:containerOrigin:
文字数: 112
所属クラス: NSLayoutManager

第9位

getLineFragmentInsertionPointsForCharacterAtIndex:alternatePositions:
inDisplayOrder:positions:characterIndexes:
文字数: 111
所属クラス: NSLayoutManager

第10位

mouseEventWithType:location:modifierFlags:timestamp:windowNumber:
context:eventNumber:clickCount:pressure:
文字数: 105
所属クラス: NSEvent

次に、メソッド名から2番目以降のメッセージキーワードを除いた部分(最初の":"まで)の長さのベスト10を調べてみました。

第1位

shouldBreakLineByHyphenatingBeforeCharacterAtIndex
文字数: 50
所属クラス: NSTypesetter, NSATSTypesetter

第2位

enterQTKitOnThreadDisablingThreadSafetyProtection
文字数: 49
所属クラス: QTMovie

getLineFragmentInsertionPointsForCharacterAtIndex
文字数: 49
所属クラス: NSLayoutManager

invalidateGlyphsOnLayoutInvalidationForGlyphRange
文字数: 49
所属クラス: NSLayoutManager

setCurrentAppleEventAndReplyEventWithSuspensionID
文字数: 49
所属クラス: NSAppleEventManager

第6位

glyphRangeForBoundingRectWithoutAdditionalLayout
文字数: 48
所属クラス: NSLayoutManager

第7位

applicationShouldTerminateAfterLastWindowClosed
文字数: 47
所属クラス: NSApplication

第8位

prepareToPullChangesInBackgroundForEntityNames
文字数: 46
所属クラス: ISyncSession

第9位

acceptConnectionInBackgroundAndNotifyForModes
文字数: 45
所属クラス: NSFileHandle

autorecalculatesContentBorderThicknessForEdge
文字数: 45
所属クラス: NSWindow

clientCommittedAcceptedChangesWithNextAnchors
文字数: 45
所属クラス: ISyncSession

pneumonoultramicroscopicsilicovolcanoconiosis(45文字)も真っ青の長さです。これを暗記できる人がいたらすごい。Xcodeのコード補完が無かった時代はどうやって入力していたんでしょうか…。