objective-ccocoafirst-responderimagekit

Why can't my subclass of IKImageBrowserView->NSView->NSResponder be made first responder?


I have this line calling -makeFirstResponder:

[self.window makeFirstResponder:libraryViewController.imageBrowser];

imageBrowser is of type CaptureBrowserView, a subclass of IKImageBrowserView, which is a subclass of NSView which is a subclass of NSResponder

@property (weak) IBOutlet CaptureBrowserView *imageBrowser;
@interface CaptureBrowserView : IKImageBrowserView
@interface IKImageBrowserView : NSView <NSDraggingSource> {
@interface NSView : NSResponder <NSAnimatablePropertyContainer, NSUserInterfaceItemIdentification, NSDraggingDestination, NSAppearanceCustomization, NSAccessibilityElement, NSAccessibility>

But I get this error:

Incompatible pointer types sending 'CaptureBrowserView *' to parameter of type 'NSResponder *'

Am I overlooking something obvious? Or is an IKImageBrowserView, for some reason, specifically unable to become the first responder?


Solution

  • Did you actually #import "CaptureBrowserView.h" in the file that does makeFirstResponder:? If the compiler has only seen a forward declaration of CaptureBrowserView at that point, it doesn't know that it's an NSResponder.