Re: Protocol implementation split between base and derived class
Re: Protocol implementation split between base and derived class
- Subject: Re: Protocol implementation split between base and derived class
- From: Scott Hancher <email@hidden>
- Date: Wed, 8 Dec 2004 16:16:19 -0800
Are you suggesting something like this?
@protocol FooProtocol1
- (void)Foo1;
@end
@protocol FooProtocol2 <FooProtocol1>
- (void)Foo2;
@end
@interface BaseFoo <FooProtocol1>
- (void)Foo1;
@end
@interface Foo : BaseFoo <FooProtocol2>
- (void)Foo2;
@end
@implementation BaseFoo
- (void)Foo1
{
NSLog( @"Foo1 called." );
}
@end
@implementation Foo
- (void)Foo2
{
NSLog( @"Foo2 called." );
}
@end
This doesn't produce any compiler warnings. I'm not quite sure why. If
I change
@interface BaseFoo <FooProtocol1>
to
@interface BaseFoo
the compiler warnings continue. It's a bit of a kludgy solution, but it
works. Thanks for the idea.
Can anyone comment on why XCode is throwing a compiler warning though?
This seems like an error to me.
++Scott.
On Wednesday, December 8, 2004, at 03:51 PM, Christian Brunschen wrote:
On 8 Dec 2004, at 23:15, Scott Hancher wrote:
You are correct. This would eliminate the compiler warning. However,
I want to leverage the compiler to warn me when I haven't implemented
all the protocol methods. Adding placeholder methods that throw an
exception would quiet the warning but would hide a potential error
that I would then have to uncover through more time consuming >> testing.
I would argue that my example Foo implements both of the FooProtocol
methods that it proclaims to conform to. The fact that one of the two
protocol methods is implemented on the base class it derives from is
immaterial.
How about you declare two protocols - one for the superclass, and one
for the subclass which just happens to include all the same methods as
the superclass' protocol?
++Scott.
// Christian Brunschen
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden