• 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: Michael Vannorsdel <email@hidden>
  • Date: Tue, 29 Apr 2008 00:25:25 -0600

You can make the superclass's method look like this:

- (void)doSomething
{
	if([self conformsToProtocol:@protocol(Check)])
		[(SuperClass <Check> *)self optionalMethodToImplement];
}

The cast eliminates the compiler warning.

As far as making it private it depends what you mean by that. If you don't want it visible in headers you're going to distribute you can put:

@protocol Check;

in the public header then actually define the whole protocol in a private undistributed header.


On Apr 28, 2008, at 9:22 PM, K. Darcy Otto wrote:

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?

_______________________________________________

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

  • Prev by Date: Re: Deleting preference file from within the application
  • Next by Date: Re: Group rotation
  • 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