Objective-C のブロックを理解する試みを続けています。私は次の機能を持っています:
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;
});
}
次のことをしようとすると:
TAnimation f = makeAnim( ... );
f();
EXC_BAD_ACCESS を取得します。ただし、代わりに次のようにすると:
TAnimation f = makeAnim( ... );
[UIView animateWithDuration:0 delay:0 options:0 animations:f completion:NULL];
それは正常に動作します。最初のシナリオの問題は何ですか?