Skip to content

Instantly share code, notes, and snippets.

@timothyekl
Created May 15, 2013 21:05
Show Gist options
  • Save timothyekl/5587371 to your computer and use it in GitHub Desktop.
Save timothyekl/5587371 to your computer and use it in GitHub Desktop.
rdar://13903643 - "NSCell does not implement methods declared in NSTextAttachmentCell protocol" NSTextAttachmentCell's documentation claims that NSCell implements all but three of its methods. This isn't the case.
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
SEL *selectors = malloc(10 * sizeof(SEL));
// The following selectors are taken from the NSTextAttachmentCell protocol reference.
// That document states that NSCell responds to all of its declared methods with three exceptions (noted below).
selectors[0] = @selector(drawWithFrame:inView:);
selectors[1] = @selector(drawWithFrame:inView:characterIndex:);
selectors[2] = @selector(drawWithFrame:inView:characterIndex:layoutManager:);
selectors[3] = @selector(highlight:withFrame:inView:);
selectors[4] = @selector(cellSize);
// skipping -cellBaselineOffset
selectors[5] = @selector(cellFrameForTextContainer:proposedLineFragment:glyphPosition:characterIndex:);
selectors[6] = @selector(wantsToTrackMouse);
selectors[7] = @selector(wantsToTrackMouseForEvent:inRect:ofView:atCharacterIndex:);
selectors[8] = @selector(trackMouse:inRect:ofView:untilMouseUp:);
selectors[9] = @selector(trackMouse:inRect:ofView:atCharacterIndex:untilMouseUp:);
// skipping -setAttachment:
// skipping -attachment
for (NSUInteger i = 0; i < 10; i++) {
SEL selector = selectors[i];
BOOL responds = [[NSCell class] instancesRespondToSelector:selector];
if (responds)
NSLog(@"NSCell instances respond to %@", NSStringFromSelector(selector));
else
NSLog(@"NSCell instances DO NOT respond to %@", NSStringFromSelector(selector));
}
free(selectors);
selectors = NULL;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment