• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Protocol-conforming object does not include retain?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Protocol-conforming object does not include retain?
      • From: Bill Bumgarner <email@hidden>
  • Prev by Date: Re: XCode 3.1 quits each time after launch
  • Next by Date: Re: Protocol-conforming object does not include retain?
  • Previous by thread: Re: Objective-C default initialization
  • Next by thread: Re: Protocol-conforming object does not include retain?
  • Index(es):
    • Date
    • Thread