Search code examples
iosobjective-cnsnotificationcenternsnotificationsnsnotification

NSNotificationCenter - Observer selectors not being called


I've gone from having all my observers selectors of multiple NSNotifications being called to none of them working. Is there an XCode/Application setting that I may have disabled that could cause this behaviour?

This issue affects just about every class that I have registered as an observer. Everything was working fine a few days ago. I'm setting the observers mainly in viewDidLoad and removing them in dealloc.

Just to add: All notifications are being posted as I have already tested for this.


Solution

  • I ended up figuring it out. I can't believe I missed this.

    The common super class for all observers was removing itself as an observer for all notifications in viewDidDisappear.

    I have now changed this to only remove itself as an observer for a specific NSNotification using [[NSNotificationCenter defaultCenter] removeObserver:name:object:];