0
我每3秒钟呼叫一次NSTimer
中的服务方法。但是,在每次调用该方法之前,我都要检查定时器中的前一个是否完成。我做了以下事情,但没有取得成功。检查NSTimer选择器是否已完成工作
timer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(CallParseOperation) userInfo:nil repeats:YES];
CheckOperation:
-(void)CheckOperation{
if([Data getInstance].kOperation == TRUE)
{
[self CallParseOperation];
}
}
CallParseOperation:
-(void)CallParseOperation{
[Data getInstance].kOperation = FALSE;
operationQueue=[[NSOperationQueue alloc] init];
ParseOperation *obj=[[ParseOperation alloc] initWithMembers:ID];
NSInvocationOperation *reloadOp = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(tableReload) object:nil];
[reloadOp addDependency:obj];
[operationQueue addOperation:obj];
[operationQueue addOperation:reloadOp];
//[operationQueue waitUntilAllOperationsAreFinished];
[obj release];
[reloadOp release];
}
某处在这个实施结束我设置这个bool
为TRUE
。但是这不起作用。控制只是卡在这个计时器内。