Re: Base class/subclass model in objective c
Re: Base class/subclass model in objective c
- Subject: Re: Base class/subclass model in objective c
- From: Jonny Taylor <email@hidden>
- Date: Fri, 18 Jun 2010 16:05:46 +0100
Thanks for your reply Jean-Daniel.
>> I can see two ways of working around this - either implement placeholder methods in the base class (that raise an exception or something) in order to make the base class conform to the protocol (knowing that in practice they should always be overridden by a subclass), or have the subclass pass its "self" pointer to the base class in the form of an id<MyProtocol> that the base class uses when it needs to call such methods. Both of these leave me feeling pretty dirty, though.
> Adding stub methods that raise an exception seam a good way to solve the problem (that what all class cluster abstract class do in Cocoa Framework).
The reason I wasn't wild on this is that it stops me getting compile-time warnings saying that the protocol is not fully implemented (since the base class fully implements it). There will be run-time errors when the non-overridden base class stub is hit. Maybe that's the best of the available choices, though. I just hoped there would be a "proper" way around this. I'm sure the language designers are far smarter than me and had good reasons for what they did, but I do miss abstract base classes!
Cheers
Jonny_______________________________________________
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