gef*_*rce 1 iphone objective-c ios objective-c-blocks
我正在为下面的代码收到这些警告.任何想法如何解决?谢谢你的帮助.
重要的是 "__block mymoviePlayerController = nil;
- (void) moviePlaybackCompleteLightBox:(NSNotification*) notification {
MPMoviePlayerController *mymoviePlayerController = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:mymoviePlayerController];
// movie fadein transition ====================
self.moviePlayerController.view.alpha = 1;
[UIView animateWithDuration:0.3f delay:0.0 options:UIViewAnimationCurveEaseOut
animations:^{
self.moviePlayerController.view.alpha = 0;
}
completion:^(BOOL finished) {
[mymoviePlayerController stop];
[mymoviePlayerController.view removeFromSuperview];
__block mymoviePlayerController = nil;
}];
}
Run Code Online (Sandbox Code Playgroud)
__block在声明变量时使用,而不是在为其赋值时使用.所以编译器将以下行视为变量声明,这是错误的:
__block mymoviePlayerController = nil;
Run Code Online (Sandbox Code Playgroud)
声明变量时应该使用__block属性:
__block MPMoviePlayerController *mymoviePlayerController = [notification object];
Run Code Online (Sandbox Code Playgroud)
PS为什么你在这里使用__block?看起来在这种情况下你不需要它
| 归档时间: |
|
| 查看次数: |
316 次 |
| 最近记录: |