• 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
Re: How to adopt a superclass's protocol?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to adopt a superclass's protocol?


  • Subject: Re: How to adopt a superclass's protocol?
  • From: "K. Darcy Otto" <email@hidden>
  • Date: Mon, 28 Apr 2008 20:22:04 -0700

Okay, I have done this, and things are compiling and running correctly. Thank you. Two additional questions then. First, I still get the warning that the superclass "may not respond" to the method (and to be sure, it is only implemented in the subclass, but the superclass calls it after a conformsToProtocol: check). Second, I would like the optionalMethodToImplement to be private - usually I put this in the .m file under a category; but when I do that with the protocol, the subclass cannot locate the protocol. Any suggestions?

On 28-Apr-08, at 5:32 PM, Michael Vannorsdel wrote:

You can specify that a class adopts a protocol by defining it as:

@interface ClassB : ClassA <Check>
{
...
}
...
@end

This will tell the compiler that ClassB implements the Check protocol. You can put multiple protocols by separating them with a comma:


@interface ClassB : ClassA <Check, someotherproto> { ... } ... @end

This will stop compiler warnings and will also warn if a class you defined to use the protocol doesn't have an implementation for the method(s) in that protocol.


On Apr 28, 2008, at 6:00 PM, K. Darcy Otto wrote:

I need to have a subclass optionally extend a method already in the superclass. After some research, my best guess is that an optionally defined protocol is the best way to go about this. So, what I have in the superclass is:

_______________________________________________

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

_______________________________________________

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: How to adopt a superclass's protocol?
      • From: Paul Sargent <email@hidden>
    • Re: How to adopt a superclass's protocol?
      • From: Michael Vannorsdel <email@hidden>
References: 
 >How to adopt a superclass's protocol? (From: "K. Darcy Otto" <email@hidden>)
 >Re: How to adopt a superclass's protocol? (From: Michael Vannorsdel <email@hidden>)

  • Prev by Date: Re: app depends on itself (???)
  • Next by Date: Re: app depends on itself (???)
  • Previous by thread: Re: How to adopt a superclass's protocol?
  • Next by thread: Re: How to adopt a superclass's protocol?
  • Index(es):
    • Date
    • Thread