This is very likely because you have a save cycle.
This, as a rule, is the case when your block implicitly holds itself, and itself saves the block in some way. You will have a hold cycle, as each one saves the other, and their keepCount will thus never reach zero.
You should activate the -Warc-retain-cycles warning, which will warn you of such problems.
So, in your case, you are using the updateResult variable, which I assume is an instance variable, and this implicitly saves self . Instead, you should use a temporary weak variable to represent yourself and use it in your block so that it does not persist and you interrupt the save cycle.
__block __weak typeof(self) weakSelf = self; // weak reference to self, unretained by the block [[NSNotificationCenter defaultCenter] addObserverForName:@"Update result" object:nil queue:nil usingBlock:^(NSNotification *note) { // Use weakSelf explicitly to avoid the implicit usage of self and thus the retain cycle weakSelf->updateResult = YES; }];
AliSoftware
source share