When I use -addObserverForName: object: queue: usingBlock: for NSNotificationCenter in the -viewDidLoad: method of my view controller, the -dealloc method ends up not being called.
(When I remove -addObserverForName: object: queue: usingBlock:, -dealloc is called again.)
Using -addObserver: selector: name: object: doesn't seem to have this problem. What am I doing wrong? (My project is using ARC.)
Below is an example of my implementation, in case I'm doing something wrong here:
[[NSNotificationCenter defaultCenter] addObserverForName:@"Update result"
object:nil
queue:nil
usingBlock:^(NSNotification *note) {
updateResult = YES;
}];
Thanks in advance for any help.
I've tried adding the following (to no avail):
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
if ([self isMovingFromParentViewController]) {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
}