Re: Help on subclassing
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