• 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
Subclassing Catch-22
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Subclassing Catch-22


  • Subject: Subclassing Catch-22
  • From: Todd Ransom <email@hidden>
  • Date: Tue, 26 Apr 2005 12:28:33 -0600

I have a controller class that has methods like this:

- (BOOL)doSomething;
- (NSString *)getInformationRequiredToDoSomething;

- (BOOL)doSomething {

	NSString *info = [self getInformationRequiredToDoSomething];
	...
}

Which works fine until I subclass. In my subclass I would like doSomething to call super for a subset of possible actions. But when I call super it calls [self getInformationRequiredToDoSomething] and returns its own info, not super's.

I thought this was a fairly common pattern in Cocoa -- overriding super's methods to do something specific and deferring to super for its own functionality. I feel like I am missing some simple rule for safely subclassing that would prevent this problem. Is there a way I can design these methods so I don't run into this problem?

Todd Ransom
Return Self Software
http://returnself.com

_______________________________________________
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


  • Follow-Ups:
    • Re: Subclassing Catch-22
      • From: Marco Scheurer <email@hidden>
  • Prev by Date: Re: NSFileModificationDate after 2039
  • Next by Date: How can a view know when its superview changes sizes?
  • Previous by thread: Re: A Question about [[self superview] doSomething]
  • Next by thread: Re: Subclassing Catch-22
  • Index(es):
    • Date
    • Thread