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 Hurrell <email@hidden>
- Date: Wed, 29 Mar 2006 13:11:37 +0200
Just for the record, I finally got to the bottom of my problems. A
stupid mistake on my part meant that my NSNotificationCenter subclass
was broken. Once I fixed the breakage everything started working.
So there is no special relationship between an NSNotificationCenter
and an NSRunLoop, other than the fact that the run loop has to run
and allow execution of the program code so that the notifications can
be posted in the first place; once posted the receiving objects will
be notified with no involvement from the run loop.
Cheers,
Greg
El 28/03/2006, a las 11:59, Greg Hurrell escribió:
Yeah, that's right, that's what I expect. But still, I'm not
getting the notifications that I send... Any idea why?
For your information, the reason I want a NSNotificationCenter
subclass is because I am trying to follow Apple's suggestion from
"Notifications: Delivering Notifications To Particular
Threads" (http://gemma.apple.com/documentation/Cocoa/Conceptual/
Notifications/Tasks/Threading.html):
A better, but more complex, implementation would generalize the
behavior into either a subclass of NSNotificationCenter or a
separate class that would have one notification queue for each
thread and be able to deliver notifications to multiple observer
objects and methods.
I have a working solution based on Apple's sample code, but when I
try to follow their advice of making a better, more generalized
solution using an NSNotificationCenter subclass, I get no
notifications at all. In my initial test attempt I've just made an
empty subclass that adds no special behaviour, but when I try
sending notifications using it the thread's run loop never "sees"
them. Swap it out and use [NSNotificationCenter defaultCenter] and
it works...
Cheers,
Greg
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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