• 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
NSNotification not going through
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSNotification not going through


  • Subject: NSNotification not going through
  • From: Matt Judy <email@hidden>
  • Date: Sat, 19 Jan 2002 15:29:39 -0800

Hi!

I'm trying to use an NSNotification to tell an NSView subclass to redraw itself for a color change.

Registering the NSView subclass as an observer:

- (id)init
{
if ( self = [super init] ) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updateColor:)
name:@"backgroundColorChanged"
object:nil];
}
return self;
}

- (void)updateColor:(NSNotification *)aNotification
{
NSLog(@"gotNotification!");
[self display];
}

And posting the notification from the controller (NSObject subclass):

- (IBAction)changeBackgroundColor:(id)sender
{
[[NSNotificationCenter defaultCenter]
postNotificationName:@"backgroundColorChanged"
object:nil];
NSLog(@"Sent backgroundColorChanged notification");
}

The method which posts the notification is being called, but the updateColor: method of the view is not. Somewhere, the Notification is not being sent or received properly. I've studied all the documentation, and I'm at a loss.

Any ideas?

Thanks!
--Matt


  • Follow-Ups:
    • Re: NSNotification not going through
      • From: Matt Judy <email@hidden>
  • Prev by Date: external editors
  • Next by Date: Window to Window handling
  • Previous by thread: Re: external editors
  • Next by thread: Re: NSNotification not going through
  • Index(es):
    • Date
    • Thread