Subclassing Catch-22
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