Reputation: 2643
i´m getting these warnings for my code below. Any ideas how to fix that? Thanks for any help.
The important line is the "__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;
}];
}
Upvotes: 1
Views: 357
Reputation: 8337
First, you don't have to set the mymoviePlayerController
variable to nil, if you don' use it afterwards. Just don't worry about it, removing the controller's view from its superview is enough.
Second, you can't make a variable writable using the __block
qualifier inside of a block. You'll have to modify your code to make the variable writable outside of the block:
__block MPMoviePlayerController *blockMoviePlayerController = mymoviePlayerController;
[UIView animate...animations:...complection:^(BOOL finished) {
blockMoviePlayerController = nil; // or something else
}];
Upvotes: 2
Reputation: 170829
__block
is used when you declare variable, not when you assign value to it. So compiler treats the following line as variable declaration, which is wrong:
__block mymoviePlayerController = nil;
You should use __block attribute when declare variable:
__block MPMoviePlayerController *mymoviePlayerController = [notification object];
P.S. Why do you use __block here anyway? It looks you don't need it in this situation
Upvotes: 5