Re: Abstract base classes in Objective C
Re: Abstract base classes in Objective C
- Subject: Re: Abstract base classes in Objective C
- From: Will Mason <email@hidden>
- Date: Thu, 14 Apr 2005 01:47:10 -0700 (PDT)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
> I want to do the following:
>
> // Exist only to provide a consistent interface
> @interface AbstractBaseClass : NSObject
> {
> }
>
> - (int) publicMethodOne;
> - (void) publicMethodTwo: (int) x;
> - (void) publicMethodThree: (int) x withModifier: (int) Y;
>
> @end
What I do, and I can't say that this is the norm, is to raise an
exception when I define what I would want to be a purely abstract
method that subclasses must override. Since Objective-C has no such
thing as pure virtual (using C++ lingo) methods, then this, as far as I
can tell, is a good solution.
GNUstep actually defines a macro for this, and I don't think that's a
bad idea. It's just a manual way of telling subclasses that if they
don't implement the method, then they are violating the design, which
is basically what C++ provides, even though C++ presents the problem at
compile time, while Objecitve-C (with this usage) presents the problem
at run time.
Good luck,
Will
_______________________________________________
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