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

subclassing question


  • Subject: subclassing question
  • From: Koen van der Drift <email@hidden>
  • Date: Sat, 12 Jul 2003 14:31:53 -0400

Hi,

My app has a baseclass with several subclasses. At one point I need to send a notification to all objects from the subclasses of baseclass. Because all objects need to get the notification, I made the baseclass the observer. From there I call the method doSomething which is handled differently in each subclass (and does nothing in the baseclass):

in baseclass:

- (void)handleNote:(NSNotification *)note
{
float = [[note object] average];
[self doSomething:average];
}

-(void)doSomething:(float)aFloat
{}

in subclass:

-(void)doSomething:(float)aFloat
{
... really do something with float
}

The problem is, only doSomething from the baseclass is called. How can I make sure that doSomething really gets called in each subclass, not only in the base class? Maybe each subclass should be an observer instead of only the baseclass?


thanks,

- Koen.
_______________________________________________
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:
    • really basic nsarray intialization question
      • From: Michael Hanna <email@hidden>
    • Re: subclassing question
      • From: Shawn Erickson <email@hidden>
  • Prev by Date: Re: Appleworks database format
  • Next by Date: Re: subclassing question
  • Previous by thread: Intializing an NSMovie with images
  • Next by thread: Re: subclassing question
  • Index(es):
    • Date
    • Thread