したがって、整数を設定するメソッドがあります。-(void)setcurrentviewfromint:(int)currentint{
これは、というクラスにありMyView
ます。私のviewDidLoad
メソッドから、私はそれを呼び出し、それも 1 に設定します:
currentview
ヘッダー ファイルに作成された int 型です
- (void)viewDidLoad
{
[super viewDidLoad];
MyView *myview = [[MyView alloc]init];
[myview setcurrentviewfromint:1];
}
次に、 にはMyView.m
、次のクラスがあります。
-(void)setcurrentviewfromint:(int)currentint{
currentview = currentint;
NSLog("currentviewis:%d",currentview);
[self setNeedsDisplay];
}
- (void)drawRect:(CGRect)rect {
NSLog(@"drawRectCalled");
if (currentview == 1) {
NSLog(@"do something here");
}
}
}
ただし、デバッガーは次のように出力します。
2012-07-18 18:02:44.211 animation[76135:f803] currentviewis:1
2012-07-18 18:02:44.223 animation[76135:f803] drawRectCalled
しかし、「ここで何かをする」は印刷されません。currentview
1に等しくない理由はありますか?