Consider this:
id observer = [[NSNotificationCenter defaultCenter]
addObserverForName:MyNotification
object:nil
As explained in the answers to
Why doesn't Remove Observer from NSNotificationCenter:addObserverForName:usingBlock get called,
you have to
__block, so that the block will refer to the initialized variable, AND__weak, to avoid a retain cycle. (The latter applies only to ARC. Without ARC,
the block does not create a strong reference to a __block variable.)Therefore:
__block __weak id observer = [[NSNotificationCenter defaultCenter] ...