Re: protocol not seeing superclass implementation : bug or feature?
Re: protocol not seeing superclass implementation : bug or feature?
- Subject: Re: protocol not seeing superclass implementation : bug or feature?
- From: Nathan Day <email@hidden>
- Date: Wed, 27 Mar 2002 21:58:18 +1030
Protocols don't work like this unfortunately but you can get a similar
effect by implementing the formal protocol as part of an informal
protocol, that is a category of the class with no implementation block.
for example
#import <AppKit/AppKit.h>
@protocol MyRectangle
- (NSRect)bounds;
@end
@interface TestView : NSView {
}
@end
@interface TestView (MyRectangle) <MyRectangle>
@ end
On Wednesday, March 27, 2002, at 06:26 PM, Michael B. Johnson wrote:
So let's say I have the following code in my TestView.h:
#import <AppKit/AppKit.h>
@protocol MyRectangle
- (NSRect)bounds;
@end
@interface TestView : NSView <MyRectangle> {
}
@end
When I compile, I get:
TestView.m:26: warning: incomplete implementation of class `TestView'
TestView.m:26: warning: method definition for `-bounds' not found
TestView.m:26: warning: class `TestView' does not fully implement the
`MyRectangle' protocol
which, given that NSView *does* implement this method, and TestView
clearly inherits from NSView, it seems silly for the compiler to
complain. Is this somehow a feature, and I'm missing it? Or is this a
genuine bug? If it's not a bug, what's the best way to not get the
error - I can obviously declare and then implement
- (NSRect)bounds {
return [super bounds];
}
but that seems silly (or again, maybe not - I think I'm just not seeing
some obvious feature of this).
Thanks for any insight.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.