Re: abstract class
Re: abstract class
- Subject: Re: abstract class
- From: Bill Bumgarner <email@hidden>
- Date: Thu, 24 May 2007 09:12:06 -0700
On May 24, 2007, at 8:44 AM, Daniel Child wrote:
I have just started studying this stuff and must be missing
something obvious, but even the gnu documentation mentions abstract
classes without giving an example. Could anyone show the briefest
example of how it works in Obj-C? Thanks in advance.
What Shawn said...
And, given:
@interface
PublicThatHappensToBeAbstraactButYourClientsDoNotKnowOrCare : NSObject
... API for your Abstract public interface here ...
+ (PublicThatHappensToBeAbstraactButYourClientsDoNotKnowOrCare *)
publicWithFoo: (Foo *) aFoo; // create a new Public from a Foo
@end
// private begins
@interface
SomeVeryConcreteSubclassThatIsTotallyOptimizedToDealWithFoos :
PublicThatHappensToBeAbstraactButYourClientsDoNotKnowOrCare
... declare whatever you need for this specific implementation ...
- initWithFoo: (Foo *) aFoo;
@end
@implementation
SomeVeryConcreteSubclassThatIsTotallyOptimizedToDealWithFoos
... your overrides of the abstract public interface that are highly
optimized for handling Foos here ...
- initWithFoo: (Foo *) aFoo;
{
... [super designatedInitializer] ...
... init with the Foo ...
return self;
}
@end
// private ends
@implementation Abstract
+ (PublicThatHappensToBeAbstraactButYourClientsDoNotKnowOrCare *)
publicWithFoo: (Foo *) aFoo; // create a new Public from a Foo
{
return
[[[SomeVeryConcreteSubclassThatIsTotallyOptimizedToDealWithFoos
alloc] initWithFoo: aFoo] autorelease];
}
@end
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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