I've setup an observer in my process using the following:
[[NSDistributedNotificationCenter defaultCenter] addObserver:__self
selector:@selector(methodA:)
name:@"NotificationName"
object:nil
suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];
I have another process that would broadcast a notification using the following:
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"NotificationName"
object:nil
userInfo:userInfo
options:NSNotificationPostToAllSessions];
Normally, the observer receives the broadcasted notifications without problems. However, on very very rare occurancies, I have seen a working observer stop responding to the broadcasted notifications. In order to verify my findings, I wrote another utility program to monitor the broadcast of distributed nofications. In the instances where the observer stop observing, the utility program registers broadcast notifications that were sent from the Distributed Notificaiton Center.
Furthermore, when the observer stops observing, I know that runloop is not stuck. As I have a timer on the main run loop that fires on regular intervals, and I do see the timer being fired while the observer had stop observing.
Are there any known reason why a previously working observer would stop receiving distributed notification?
How can I programatically check that the observer is broken?
And if I can detect that the observer is broken, would removing and creating a new observer solves the issue?
This issue has been very diffcult to troubleshoot, as I cannot determine the reason why the notification observer suddenly stop working.