我了解 ARC 中的 __block 保留了该变量。然后可以在分配变量之前访问块中的变量时使用它,如下所示:
__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?
}];
但我无法解析这个。如果__block
导致观察者被块保留,那么有效地同时强和弱意味着什么?在这里做什么__weak
?