discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: protocols being implemented in the superclass


From: Alexander Malmberg
Subject: Re: protocols being implemented in the superclass
Date: Fri, 13 Dec 2002 14:50:13 +0100

Stefan Böhringer wrote:
> 
> A problem I encountered with gcc3.2 (but which is probably present with
> other versions, too) is as follows:
> 
[snip example]
> 
> If the methods are implemented exactly as they are declared (i.e. no
> additional implementations in the .m files) I get warnings about
> -methodB not being implemented by class "Subclass" though it is through
> "Superclass". This seems to need a fix in the compiler.

Depends on what kind of behavior you want. The current behavior is
sometimes a bit unexpected, but it isn't incorrect, since:

@interface Superclass : NSObject <NSCoding>
{
        int ivar1_that_should_be_encoded;
}
-(void) encodeWithCoder: (NSCoder *)coder;
@end

@interface Subclass : Superclass <NSCoding>
{
        int ivar2_that_should_be_encoded;
}
@end

Here you _should_ get a warning if you don't implement
-encodeWithCoder:, since in this case Subclass must implement
-encodeWithCoder: to encode ivar2_that_should_be_encoded. The
superclass's implementation of a protocol (or method in a protocol)
doesn't automatically mean that all subclasses implement the protocol.

> Stefan

- Alexander Malmberg



reply via email to

[Prev in Thread] Current Thread [Next in Thread]