I am calling a service method in NSTimer
after every 3 seconds. However before each time that method is being called, I want to check if previous one in timer is complete or not. I have done following which is not resulting in success.
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];
}
Somewhere at the end of this implementation I am setting this bool
as TRUE
. But this is not working. The control is just stuck inside this timer.