NSTimer를 무효화 할 수 없습니다. 계속 실행됩니다. 클래스다른 클래스의 nstimer를 무효화합니다.
내가 가지고
는-(void)startMachine
{
NSLog(@"START THE MACHINE ");
doesOn=1;
machineClock=[NSTimer scheduledTimerWithTimeInterval:0.05
target:self
selector:@selector(recordMachine:)
userInfo:nil
repeats:YES];
....//machineClock is on the .h file in interface
}
-(void)recordMachine:(NSTimer*)timer
{
NSLog(@"recordMachine");
...
-(void)stopMachine
{
NSLog(@"STOP THE MACHINE !! ");
[machineClock invalidate];
machineClock=nil;
...
}
는 클래스 B, 시작과 중지에 :
classAinst=[recordMachine alloc];
[classAinst startMachine]; //it starts here.
......
[classAinst stopMachine]; //it class the method to stop it,but the timer still ticks.
어떤이의 원인? 타이머에 대한 속성을 만들어야합니까? 클래스 a가 b에서 타이머를 보유하고 있으므로 no를 중지해야합니까? 당신은 또한 그것의 통제를 잃은 이유
한번만 시작 하시겠습니까? – Alexander
예, 확신합니다. – user1280535
@ user1280535 레코드를 중지 할 때 명확하게하기 위해 "기계 중지"가 인쇄되지만 "레코드 머신"은 여전히 인쇄 중입니까? – janusbalatbat