Question

I have a subclass of IASKAppSettingsViewController that I, of course, use to display and handle various events for the settings I present to the user. In this subclass, I am trying to receive the notification that settings were changed by adding this line to -(void)viewDidLoad:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(settingsChanged:) name:kIASKAppSettingChanged object:nil];

Problem is that the method, settingsChanged, is never being called. I figure that there is some other way of doing this or I am doing something wrong here. This procedure does work for me in other classes, so I assume there is something special about IASKAppSettingsViewController that is preventing this from working. Can someone point me in the right direction?

EDIT #1

Received a message from Future Tap via GitHub and he asked me to check the sample app. I did and the sample app does not use a subclass of IASKAppSettingsViewController. I have since added another addObserver and that is also not being called. I verified that both addObserver calls are being executed, so that is not the cause.

EDIT #2

It appears that something is terribly amiss in my app. I have multiple classes that observe this notification and they all use the same name for the method to be called (settingsChanged). When I Command-click the name of the method in one addObserver call, Xcode brings me to another class' settingsChanged method. This is probably what is causing some of my observer methods not to get called.

Was it helpful?

Solution

Working with Future Tap, we discovered that `IASKAppSettingsViewController' was removing all observers when the view disappeared. This was causing the observers that I set up to be removed and, thus, not be called. The code has been fixed and my problem is solved.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top