1

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;

                         }];

    }
4
  • have you declared "mymoviePlayerController" in your .h file also?? i mean both locally and globally?? Commented Jul 26, 2012 at 11:21
  • Also specify the line where you are getting the first and second warning Commented Jul 26, 2012 at 11:22
  • "The important line is the "__block mymoviePlayerController = nil;" This throws the warning. Commented Jul 26, 2012 at 12:16
  • 1
    If you are using ARC then you do not need to write this line. [removefromSuperview] does that. Commented Jul 26, 2012 at 12:18

2 Answers 2

5

__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

Sign up to request clarification or add additional context in comments.

Comments

2

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

1 Comment

Thanks to Vladimir and Fabian for their help. Good to know. It fixes the problem. Thanks for your fast reply. Have a nice day.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.