• 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: Help on subclassing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help on subclassing


  • Subject: Re: Help on subclassing
  • From: Sherm Pendley <email@hidden>
  • Date: Thu, 1 Dec 2005 14:19:31 -0500

On Dec 1, 2005, at 2:01 PM, Joachim wrote:

Thanks for the input. When reading "The Objective-C Programming Language" a few months back, I didn't think I would need protocols... But still, it doesn't seem to do the trick.

It still requires class A to implement the someMethod, and that's exactly what I don't want. That method will only exist in A's subclasses, B and C. So I might want to make a protocol that both B and C conforms to, but it still doesn't solve my problem:

You could declare the method in an "informal protocol" on class A:

@interface A : NSObject
{
}
@end

@interface A (PureVirtualMethods)

- (NSRect) someMethod;

@end

Now, you don't need to provide an implementation of -someMethod in class A. But, you do need to re-declare the methods in the interfaces for Classes B and C:

@interface B : A
{
}
@end

@interface B (PureVirtualMethods)
- (NSRect) someMethod;
@end

Naturally, you need to provide implementations for these methods in B and C.

sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: Help on subclassing
      • From: Joachim <email@hidden>
References: 
 >Re: Help on subclassing (From: Joachim <email@hidden>)

  • Prev by Date: Re: Help on subclassing
  • Next by Date: Re: change app name in dock on the fly
  • Previous by thread: Re: Help on subclassing
  • Next by thread: Re: Help on subclassing
  • Index(es):
    • Date
    • Thread