Objective C: Where to remove observer for NSNotification?
I have an objective C class. In it, I created a init method and set up a NSNotification in it //Set up NSNotification [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getData) name:@"Answer Submitted" object:nil]; Where do I set the [[NSNotificationCenter defaultCenter] removeObserver:self] in this class? I know that for a UIViewController , I can add it into the viewDidUnload method So what needs to be done if I just created an objective c Class? The generic answer would be "as soon as you no longer need the notifications". This is obviously not a satisfying answer. I