Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Parameter name omitted

I'm trying to have an auto reversing animation, and am getting the above error on the "completion:^(BOOL)finished{" line.

            [UIView animateWithDuration:0.5 
                              delay:0
                            options:UIViewAnimationOptionAutoreverse
                         animations:^{
                             [[[self dieButtons] objectAtIndex:i] setTransform:CGAffineTransformMakeTranslation(0, 200)];
                         }
                         completion:^(BOOL)finished{

                         }];

Note I first attempted this with the following code but the button jumped to the new location at the end of the animation.

        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.5];
        [UIView setAnimationRepeatAutoreverses:YES];
        [button setTransform:CGAffineTransformMakeTranslation(0, 200)];
        [UIView commitAnimations];
like image 958
Joe_Schmoe Avatar asked Feb 26 '11 20:02

Joe_Schmoe


1 Answers

finished is the name of the BOOL parameter, and Objective-C blocks have C-style function signatures, so it has to be in the parentheses.

The block's signature is supposed to look like this:

^(BOOL finished) {
}
like image 138
BoltClock Avatar answered Oct 21 '22 03:10

BoltClock