1
votes

i´m getting these warnings for my code below. Any ideas how to fix that? Thanks for any help.

  • Type specifier missing, defaults to 'int'
  • Incompatible pointer to integer conversion initializing 'int' with an expression of type 'void *';
  • Unused variable 'mymoviePlayerController'

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;

                         }];

    }
2
have you declared "mymoviePlayerController" in your .h file also?? i mean both locally and globally?? - Tripti Kumar
Also specify the line where you are getting the first and second warning - Tripti Kumar
"The important line is the "__block mymoviePlayerController = nil;" This throws the warning. - geforce
If you are using ARC then you do not need to write this line. [removefromSuperview] does that. - Tripti Kumar

2 Answers

5
votes

__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

2
votes

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
}];