Re: compiler warning for not fully implementing protocol
Re: compiler warning for not fully implementing protocol
- Subject: Re: compiler warning for not fully implementing protocol
- From: Mark Sanvitale <email@hidden>
- Date: Fri, 1 Aug 2008 03:53:47 -0700
I copied your code from Mail and pasted it into a text file.
[ip193:~/Desktop] mas% cc test.m -framework Foundation -o test
test.m:33: warning: incomplete implementation of class
'PortalActionView'
test.m:33: warning: method definition for '-displayCapture' not found
test.m:33: warning: class 'PortalActionView' does not fully implement
the 'ReadArchiveClient' protocol
Yes, you are correct that "PortalActionView conforms" is printed out
when you run the resulting program. That is exactly my point.
Everything is fine. The runtime knows it. But at build time the
compiler thinks otherwise.
Of course, perhaps these warnings are not actually being output on
other systems. I am running 10.4.11, 'cc --version':
i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build
5370).
But, hey, the warnings are harmless and can even be avoided with the
elegant:
- (id)displayCapture { return [super displayCapture]; }
I will just write a bug and see what the powers that be think.
Thanks.
On Jul 31, 2008, at 8:13 PM, Adam R. Maxwell wrote:
On Jul 31, 2008, at 4:14 PM, Mark Sanvitale wrote:
I think I am doing exactly what you say is necessary (i.e. declare
the second method in the superclass's public interface).
Here are some code snippets:
Turning your code snippets into a test program, I can't reproduce
that compiler warning, or in a trivial test where the superclass
declares/implements copyWithZone: and the subclass declares
conformance. If this works for you, what did I miss?
// File test.m, compile & run with `cc test.m -framework Foundation
-o test && ./test`
#import <Foundation/Foundation.h>
@protocol PortalTabProtocol
- (void)refreshDisplay:(id)capture because:(int)trigger;
@end
@interface PortalTabView : NSObject <PortalTabProtocol>
- (NSString *)tabName;
- (void)refreshDisplay:(id)capture because:(int)trigger;
- (id)displayCapture;
@end
@protocol ReadArchiveClient
- (id)displayCapture;
- (void)processedArchive:(id)archive;
@end
@interface PortalActionView : PortalTabView <ReadArchiveClient>
@end
@implementation PortalTabView
- (NSString *)tabName; { return nil; }
- (void)refreshDisplay:(id)capture because:(int)trigger; {}
- (id)displayCapture; { return nil; }
@end
@implementation PortalActionView
- (void)processedArchive:(id)archive {}
@end
int main (int argc, char const *argv[])
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
id obj = [[PortalActionView alloc] init];
if ([obj conformsToProtocol:@protocol(ReadArchiveClient)])
NSLog(@"PortalActionView conforms");
else
NSLog(@"PortalActionView does not conform");
[pool release];
return 0;
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden