그래서 정수를 설정하는 메서드가 있습니다 : -(void)setcurrentviewfromint:(int)currentint{
이것은 클래스가 MyView
입니다. 내 viewDidLoad
방법에서, 나는 그것을 호출하고도 1로 설정 :정수 할 수 없다 == 비교
-(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");
}
}
}
:
currentview
는
- (void)viewDidLoad
{
[super viewDidLoad];
MyView *myview = [[MyView alloc]init];
[myview setcurrentviewfromint:1];
}
그럼 내 헤더 파일에 생성 MyView.m
에서, int 타입이다, 나는이 수업을
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과 같지 않은 이유는 무엇입니까?
"그러나 컴파일러 인쇄를"사용하십시오 될 것으로 기대한다. .. 컴파일러에서 오는 것이 확실합니까? –
멀티 스레딩 문제가 있습니까? 'currentView'의 값을 어디에서 설정하고 있습니까? –
"currentviewis : 1"메시지가 표시되지 않습니다. (즉, 먼저 인쇄 된 "1"메시지는 setcurrentviewfromint :에서 인쇄 한 것과 일치하지 않습니다.)'viewDidLoad'가 실제로 호출 되었습니까? – Turix