Is it possible to use first -removeObserver:and then call -addObserver:with the same name? Or is it a rule to have -addObserver:before -removeObserver:?
I tried this with OS 4.0, and it seems like it is normal (without crashes, warnings, etc.).
-(void) setObserver
{
[[NSNotificationCenter defaultCenter] removeObserver:self
name:OBSERVER_NAME object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector: @selector(selectorName)
name:OBSERVER_NAME
object:nil];
}
The reason is that two observers with the same method should be selectorNamecalled twice, assuming that the method -setObserverwas called again if it was issued inside -viewDidLoadand a warning about memory.
Also do I need to call -removeObserver:on time -dealloc?
source
share