Protocol-conforming object does not include retain?
Protocol-conforming object does not include retain?
- Subject: Protocol-conforming object does not include retain?
- From: Steve Weller <email@hidden>
- Date: Fri, 11 Jul 2008 19:39:07 -0700
I have a protocol and an object that conforms to that protocol
referenced by an ivar:
@protocol FKPointArraySourcing
-(NSInteger)fooMethod;
@end
@interface FKObject : NSObject <FKPointArraySourcing> {
id <FKPointArraySourcing> mGrid;
}
If I attempt to retain the ivar like this:
[mGrid retain];
then I get a warning that "-retain was not found in protocol(s)".
If I change the protocol definition to:
@protocol FKPointArraySourcing <NSObject>
-(NSInteger)foo;
@end
then the warning goes away.
If I remove the protocol conformance and just use a naked id, then the
warning goes away as well.
Or if I cast mGrid to id the warning goes away.
Why is this addition needed? I don't see it used in other code. It's
as though the compiler believes that conformance to a protocol implies
that it exclusively provides those methods, which is not the idea of
protocol conformance at all.
Steve Weller email@hidden
Technical Writing, Editing, Developer Guides, and a little Cocoa
_______________________________________________
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