Re: CFNotificationCenter ./. NSNotificationCenter
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:mime-version:in-reply-to :references:content-type:message-id:content-transfer-encoding:from :subject:date:to:x-mailer; bh=VQNwGwgSGtkGAyV4jlV8KG6PSN57vqTnfCd9AdroeUg=; b=BVElhcVoLPZT2kDD7aVeo8EcW8bqol3VWXkXJNo2xRg9x+2/1eT+mAtO46Bch4aPDy divH/5Ig8rq7KgZMuzDIa8BKilrAla7ARGTw3XfoNLb4rcuDZxAvuBgWhXXMAtcG4rLp KUVkSfh3y4Dsu22Lpp413JOan3rqBPrxT8khs= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:content-type:message-id :content-transfer-encoding:from:subject:date:to:x-mailer; b=NepKy8xrQb+rHqHUcz5eqwNq2KP7skEFb0QI3lgQkXzdsq4xD3V22G42GWpVA9t4P2 oSi65QIlOi6UmdT6UrhFM3+lJUCYPO5UfmZuZthLSro9JuQsCpapDWh9IM30B3ugmC3J I0tQ1iDQwPkWd7eJf61kd+JOE3yc8Y5oxylGE= On Feb 27, 2010, at 12:59 PM, Hado Hein wrote: 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?
From the documentation: . 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... Thanks for the help on CFSocket. Finally I left my code as it is - using socket. . It's definitely not a good idea to use the NSNotificationCenter architecture to communicate between 2 threads: "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. This email sent to site_archiver@lists.apple.com
participants (1)
-
Iceberg-Dev