Joe_Schmoe
Joe_Schmoe

Reputation: 1484

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

Upvotes: 6

Views: 7540

Answers (1)

BoltClock
BoltClock

Reputation: 723398

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) {
}

Upvotes: 26

Related Questions