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

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.

  • Follow-Ups:
    • Re: subclass weirdness
      • From: Koen van der Drift <email@hidden>
References: 
 >subclass weirdness (From: Koen van der Drift <email@hidden>)

  • Prev by Date: subclass weirdness
  • Next by Date: Re: Newbie question
  • Previous by thread: subclass weirdness
  • Next by thread: Re: subclass weirdness
  • Index(es):
    • Date
    • Thread