Re: Multiple notification calls?
Re: Multiple notification calls?
- Subject: Re: Multiple notification calls?
- From: Chris Kane <email@hidden>
- Date: Wed, 15 Jun 2005 11:31:35 -0700
NSNotificationCenter does not do any uniquing of registrations, so
the simplest explanation is that you're registering for the
notification multiple times, or for multiple objects. (Since object:
is nil in your registration, any object sending out that notification
name will cause you to receive it, and the object: parameter in the
posting is not significant.)
Chris Kane
Cocoa Frameworks, Apple
On Jun 9, 2005, at 5:34 PM, Mark Dawson wrote:
In one part of my code, I post a notification. However, the code
that gets the notification gets called 3-4x. I'm not sure why.
The code only goes through the notification routine once (doing a
"continue" goes to the notification routine 4x, without going back
to the code that posts the notification). I'm not sure how to
debug this…I'm compiling on XCode 1.5, 10.3.9…
Thanks for any help!
mark
// setup of the notification
NSNotificationCenter *center = [NSNotificationCenter
defaultCenter] ;
[center addObserver: self
selector: @selector(levelDidChangeNotification:)
name: defaultsDidChangeNotification_Level
object: nil];
...
// notification routine
- (void)levelDidChangeNotification:(NSNotification *)notification
{
#pragma unused (notification)
unsigned short newLevel = [mPopUpButton indexOfSelectedItem];
if (newLevel != [mLevels curLevel])
{
[mPopUpButton selectItemAtIndex:[mLevels curLevel]];
}
}
...
// code that sends the notification
[[NSNotificationCenter defaultCenter] postNotificationName:
defaultsDidChangeNotification_Level object:self];
_______________________________________________
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
_______________________________________________
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