,這是另一個新手問題 - 流程/工作流程問題。請耐心等待。基於「自來水」我怎麼訪問定時器對象並停止處理
我有一個的NSTimer對象,計時器,在一個方法梅塔創造,傳遞到它是用來contorl一些處理的另一種方法methB。兩種方法都屬於同一類。
我有touchesBegin和touchesEnded方法來捕捉用戶輸入。這些方法與我之前的兩個方法 - methA和methB在同一個類中。當用戶「點擊」我的屏幕上我需要停止處理
當我的touchesBegin方法是由水龍頭調用我假設我所要做的就是發送一條消息給我的其他方法,methA/methB和告訴他們停止處理。我假設我所要做的就是使傳遞給我的「處理」方法(即methB)的計時器無效。
這聽起來是正確的?我已經包含了我的四個方法touchesBegin,methA和methB。任何輸入是不勝感激。
- (void) methA
{
stepValue = 0;
animationBuild = YES;
float duration = [[[Config shared] valueForKey:@"animation.val.step_duration"] floatValue];
[NSTimer scheduledTimerWithTimeInterval:duration target:self selector:@selector(stepValue:) userInfo:nil repeats:YES];
}
- (void) methB:(NSTimer *) timer
{
if (animationBuild)
{
// animation logic/processing
}
// Next step
stepValue++;
if (stepValue == GROUP_SIZE)
{
[timer invalidate];
[self animateShowMessage];
}
}
- (void) touchesBegan:(NSSet *) touches withEvent:(UIEvent *) event
{
if (modalDialog)
{
return;
}
if (currentTouch == nil)
{
UITouch *touch = [[touches allObjects] objectAtIndex:0];
currentTouch = [touch retain];
}
}
- (void) touchesEnded:(NSSet *) touches withEvent:(UIEvent *) event
{
if (modalDialog)
{
return;
}
UITouch *touch = [[touches allObjects] objectAtIndex:0];
if ((touch != nil) && (touch == currentTouch))
{
CGPoint touchPoint = [touch locationInView:self.view];
else if ((CGRectContainsPoint(visRect[[Process shared].procType], point)) && (touch.tapCount == 2))
{
// processing
}
else
{
// Start a new processing
[self startNew];
}
[currentTouch release];
currentTouch = nil;
}
}