ヘッダーに記載されているivarがあります
@interface MyClass : UIView{
int thistone;}
- (IBAction)toneButton:(UIButton *)sender;
@property int thistone;
@end
実装で合成しました:
@implementation MyClass
@synthesize thistone;
- (IBAction)toneButton:(UIButton *)sender {
if(thistone<4)
{thistone=1000;} // I hate this line.
else{thistone=thistone+1; }
}
ゼロ以外の初期値を設定する方法が見つかりません (またはマニュアルで見つかりません)。1000 から開始して、ボタンを押すたびに 1 ずつ増やしていきます。コードは私が意図したとおりに動作しますが、上記の if/else ステートメントを節約できる、より適切な方法があると思います。コードの修正またはオンライン ドキュメントの特定の行へのポインタは大歓迎です。