I\'m confused on why the observer is never removed in the following code. In my viewDidAppear I have the following:
-(void)viewDidAppear:(BOOL)animated{
id
I find that in fact there is a memory leak unless the observer is marked both __block and __weak. Use Instruments to make sure that self is not being overretained; I bet it is. This, however, works correctly (from my actual code):
__block __weak id observer = [[NSNotificationCenter defaultCenter]
addObserverForName:@"MyMandelbrotOperationFinished"
object:op queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification *note) {
// ... do stuff ...
[[NSNotificationCenter defaultCenter]
removeObserver:observer
name:@"MyMandelbrotOperationFinished"
object:op];
}];