views:

32

answers:

0

Continuing to try to understand blocks in Objective-C. I have the following function:

typedef void(^TAnimation)(void);
TAnimation makeAnim(UIView *aView, CGFloat angle, CGFloat x, CGFloat y, 
                    CGFloat width, CGFloat height, UIInterfaceOrientation uiio) {
    return Block_copy(^{
        aView.transform = CGAffineTransformMakeRotation(angle);
        aView.frame = CGRectMake(x, y, width, height);
        [UIApplication sharedApplication].statusBarOrientation = uiio;
    });
}

When I try to do the following:

TAnimation f = makeAnim( ... );
f();

I get an EXC_BAD_ACCESS. However, if I do the following instead:

TAnimation f = makeAnim( ... );
[UIView animateWithDuration:0 delay:0 options:0 animations:f completion:NULL];

it works fine. What is the problem in the first scenario?