• 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: abstract class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: abstract class
      • From: Daniel Child <email@hidden>
    • Re: abstract class
      • From: Serge Cohen <email@hidden>
References: 
 >abstract class (From: Daniel Child <email@hidden>)

  • Prev by Date: Re: Thread Pools in Cocoa / ObjC?
  • Next by Date: NSImage quality, blurred characters
  • Previous by thread: Re: abstract class
  • Next by thread: Re: abstract class
  • Index(es):
    • Date
    • Thread