Re: subclass weirdness
Re: subclass weirdness
- Subject: Re: subclass weirdness
- From: Andy Lee <email@hidden>
- Date: Sun, 29 Jun 2003 22:51:05 -0400
At 10:35 PM -0400 6/29/03, Koen van der Drift wrote:
Hi,
I thought by now I understand subclassing, but this is driving me crazy ;)
Consider a base class and it's subclass: MyBase and MySub, both of
which have a method foo to which I pass an NSString:
-(void)foo:(NSString *)s
{
blahWithString...
}
and for MySub:
-(void)foo:(NSString *)s
{
[super foo:s];
moreBlahWithString...
}
When I call [mySub foo:aString], only the base class gets called, so
moreBlahWithString never gets executed. I stared at this too long
now, and I don't see what's wrong.
any ideas?
When staring fails, it's time to resort to brute-force debugging.
Put in NSLog() statements. Make sure the "mySub" in your "[mySub
foo:aString]" statement is in fact an instance of MySub and not
MyBase. It's simple to do:
NSLog(@"mySub is an instance of %@", [mySub className]);
You could also try posting excerpts of your actual code.
Make sure you capitalized the methods names identically in the two classes.
--Andy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.