• 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: Daniel Child <email@hidden>
  • Date: Fri, 25 May 2007 01:04:39 -0400

Shawn,

If you provide no implementation code for someAbstractMethod under AbstractClass, then when the user calls

AbstractClass * myNewObject = [[AbstractClass alloc] init];
[myNewObject someAbstractMethod];

how is it going to get booted down to the subclass's implementation of someAbstractMethod (the one which does the work)?

On May 24, 2007, at 12:00 PM, Shawn Erickson wrote:

You can do this using various patterns... so the following is just one
example and likely the laziest of them. You can take further steps to
actually flag incorrect usage at runtime (attempts to instantiate the
base class, etc.) but often those are over kill IMHO.

// document that the following class is abstract
@ interface AbstractClass : NSObject {
   ...
}
- (void) someAbstractMethod;
... other methods ...
@end

@implementation AbstractClass
// document that the following method is abstract
- (void) someAbstractMethod {}
@end

@interface ConcreteClass :  AbstractClass {
   ...
}
... other methods ...
@end

@implementation ConcreteClass
- (void) someAbstractMethod {
   ... implementation ...
}
@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: Shawn Erickson <email@hidden>
References: 
 >abstract class (From: Daniel Child <email@hidden>)
 >Re: abstract class (From: "Shawn Erickson" <email@hidden>)

  • Prev by Date: Re: Cocoa-dev Digest, Vol 4, Issue 496
  • Next by Date: adding an NSPDFImageRep to an NSImage scales (down) image
  • Previous by thread: Re: abstract class
  • Next by thread: Re: abstract class
  • Index(es):
    • Date
    • Thread