Re: How to associate a custom NSNotificationCenter with an NSRunLoop in a thread?
Re: How to associate a custom NSNotificationCenter with an NSRunLoop in a thread?
- Subject: Re: How to associate a custom NSNotificationCenter with an NSRunLoop in a thread?
- From: Greg Herlihy <email@hidden>
- Date: Mon, 27 Mar 2006 13:53:10 -0800
- Thread-topic: How to associate a custom NSNotificationCenter with an NSRunLoop in a thread?
A notification center is conceptually a singleton - it works best because
all parties use the same one. And while you can create your own notification
center - only your code will even know that it exists. So the only kind of
notifications an object could ever expect to receive from this center, are
those notifications that the application has sent to this center, itself.
Greg
On 3/27/06 5:25 AM, "Greg Hurrell" <email@hidden> wrote:
> In the worker thread of my multi-threaded app I find that I can
> register for notifications from the default notification center (as
> returned by [NSNotificationCenter defaultCenter]) and I receive those
> notifications when I run the worker thread's run loop (as returned by
> [NSRunLoop currentRunLoop]).
>
> I am aware of the limitation that notifications will be received on
> the thread from which they were posted. That's not the problem.
>
> The problem is that if I try to use a different notification center,
> for example, an NSNotificationCenter subclass, then I find that I
> don't ever receive any notifications. Evidently the default
> NSNotificationCenter has some kind of relationship with the current
> NSRunLoop and it all just works automatically. But if you are using a
> different center, you evidently need to set a relationship up between
> it and the run loop, otherwise you'll never receive any notifications
> when you run the run loop.
>
> The question is, how? And what exactly needs to be done? My
> inspection of by the NSNotificationCenter and NSRunLoop
> documentation, as well as a class dump of those classes, doesn't
> provide me any clues. I can see neither methods in
> NSNotificationCenter for adding or registering run loops, nor methods
> in NSRunLoop for adding or registering NSNotificationCenters. I can
> only see methods for adding ports and timers to run loops, and there
> are no methods in NSNotificationCenter for getting at any underlying
> ports that it may (or may not) be using.
_______________________________________________
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