I understand that __block in ARC retains the variable. This can then be used when accessing a variable within a block before the variable has been assigned, as in:
__block __weak id observer = [[NSNotificationCenter defaultCenter] addObserverForName:MPMoviePlayerPlaybackDidFinishNotification object:player queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification* notif){
// reference the observer here. observer also retains this block,
// so we'd have a retain cycle unless we either nil out observer here OR
// unless we use __weak in addition to __block. But what does the latter mean?
}];
But I am having trouble parsing this. If __block
causes the observer to be retained by the block, then what does it mean to effectively be both strong and weak? What is the __weak
doing here?