poorDeveloper
poorDeveloper

Reputation: 515

NSNotification not received

I have a multithreaded program sending messages through NSNotificationCenter (addObserver:.. and postNotification:... methods).

The threads are subscribed for different notifications, some of them shared, so that a message should be received in various threads.

Normally, all the notifications are properly received and processed in all the threads, but sometimes the callback function of the notification is not invoked in some of the threads that are listening for the notification.

Is there a way of assure that all my notifications will be processed by all the subscribed threads?

Upvotes: 1

Views: 405

Answers (2)

Andrea
Andrea

Reputation: 26383

NSNotificationCenter launch the registered mehod on the same thread where the original notification has fired. Are you sure that this thread is still alive?

Upvotes: 0

Guy Kogus
Guy Kogus

Reputation: 7351

What matters isn't the thread on which you subscribe to the notification, but the thread on which the notification is posted. You'd probably have to write your own notification manager to make this happen. I don't think it would be overly complicated, and I would recommend to use dispatch_queue_ts rather than threads.

Upvotes: 1

Related Questions