컨트롤러에 끌어서 놓기 기능을 위임 할 수 있도록 NSImageView를 확장하려고합니다. 컴파일러가 유형 ID를 가진 객체에 메시지를 보내는 것에 대한 경고를 표시하는 한 가지 문제로 모두 잘 작동합니다. 이를 해결하기 위해 나는 ivar의 형식에 프로토콜의 이름을 붙이기 만하면된다고 가정했습니다. 그러나 이것은 프로토콜에 대한 정의를 찾을 수 없다는 메시지와 함께 비참하게 실패합니다.objective-C에서 프로토콜 정의 및 사용
#import <Cocoa/Cocoa.h>
@interface DragDropImageView : NSImageView {
id <DragDropImageViewDelegate> _delegate;
}
@property (readwrite, retain) id <DragDropImageViewDelegate> delegate;
@end
@protocol DragDropImageViewDelegate
@optional
- (NSDragOperation)dragDropImageView:(DragDropImageView *)ddiv validateDrop:(id <NSDraggingInfo>)info;
- (BOOL)dragDropImageView:(DragDropImageView *)ddiv acceptDrop:(id <NSDraggingInfo>)info;
- (void)concludeDragOperation:(id <NSDraggingInfo>)sender;
@end
내가 잘못 가고있는 포인터는 무엇입니까? 나는 그것이 단순해야만한다고 확신하지만 obj-c에 대해서는 아주 새로운 것이다.
+1 좋은 질문입니다. –
키워드는 다음과 같습니다. _forward declaration_. – holex