Re: CFNotificationCenter ./. NSNotificationCenter
Re: CFNotificationCenter ./. NSNotificationCenter
- Subject: Re: CFNotificationCenter ./. NSNotificationCenter
- From: Iceberg-Dev <email@hidden>
- Date: Sat, 27 Feb 2010 18:10:41 +0100
On Feb 27, 2010, at 12:59 PM, Hado Hein wrote:
Thanks for the help on CFSocket. Finally I left my code as it is -
using
socket.
Now I'm trying to get the data I received out of my thread.
I'm posting a CFNotification to the local center.
CFNotificationCenterPostNotification(
CFNotificationCenterGetLocalCenter(), CFSTR("news"), NULL, nfodict,
false);
But in some other thread I'm not receiving it.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(NoteCallBack:) name:@"news" object:NULL];
In two threads (in one application) do I need to use the distibuted
center?
. It's definitely not a good idea to use the NSNotificationCenter
architecture to communicate between 2 threads:
From the documentation:
"In a multithreaded application, notifications are always delivered
in the thread in which the notification was posted, which may not be
the same thread in which an observer registered itself."
To communicate between 2 threads, you can use Message Port for
instance, they work reliably.
. Just to be pedantic, it's not object:NULL but object:nil.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden