error: synthesized property 'foobar' must either be named the same as a compatible ivar or must explicitly name an ivar
いま実機でないと重要な機能が試せないアプリを作っていて、それ以外の機能を作るのでシミュレータでいいかと思ってSDKを切り替えたらこういうエラーが出るようになった。
error: synthesized property 'foobar' must either be named the same as a compatible ivar or must explicitly name an ivar
要するに
@interface BazQuux { } @property (nonatomic, retain) FooBarType *foobar;
でiPhone実機用のSDKだとビルドできるけど、シミュレータ用のSDKでは
@interface BazQuux { FooBarType *foobar; } @property (nonatomic, retain) FooBarType *foobar;
と書かなければ行けないということ。@synthesize foobar;の下でエラーメッセージがでるので当惑した。
error: synthesized property 'foobar' must either be named the same as a compatible ivar or must explicitly name an ivar
@synthesizeされるプロパティ'foobar'は、代入互換性のあるivarと同じ名前を付けられているか、または明示的にivarをつける必要がある。
なお、仕様上は一つ目のコードで動くはずで、これはシミュレータ用SDKのバグである、という主張が下のページに書いてあった。
iPhone Simulator: build errors when using synthesized instance variables - Stack Overflow
flipするアニメーション
[UIView setAnimationDuration:1]の単位をミリ秒だと勘違いして1000って入れていたせいでアニメーションがうまく設定されていないように見えて(実は超スロー)はまった。
[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1]; [UIView setAnimationTransition:([self.optionView superview] ? UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight) forView:self.view cache:YES]; if ([self.optionView superview]){ [self.optionView removeFromSuperview]; [self.view addSubview:self.mainView]; }else{ [self.mainView removeFromSuperview]; [self.view addSubview:self.optionView]; } [UIView commitAnimations];