I'm having some issues where my posted notification:
[[NSNotificationCenter defaultCenter] postNotificationName:@"MobileProviderChanged"
object:self.selectedProviderID];
Is not being trapped by my observer:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(onProviderChanged:)
name:@"MobileProviderChanged"
object:nil];
The exact same observer works correctly in a different ViewController.
Any tips on methods to debug this further to see what messages are actually posted to the defaultCenter?
Thanks.
The more I research this issue I wonder if my problem is that the sending viewcontroller is on a different thread than the observing viewcontroller.
Incorrect multi-threading is almost assuredly the source of your problem. However, the notifications should still be sent and received.
Specifically, a notification will be received on whatever thread it was sent upon. Since you mention that you are mucking about with view controllers in response to the notification, it is quite likely you are doing something on a non-main thread that the UIKit is unhappy about.
Got the same problem. Solution is quite simple, but not obvious:
Make sure, that the observer still exists during NSNotification delivery.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With