Reputation: 359
I have to develop an application where it does following things,
I implemented this by using a if condition
if(output>10){
[[shared sharedInstance].counter++;
}
(all above are implemented and they work perfectly)
BUT the problem is.....................
I want to check this if condition, used to update to be active for 5ms and deactivate for 10ms but it's also important to "NOT" to stop the accelerometer data process and calculating output.
So i thought that i can implement two global variables and set their values as shown below 1. var_x - set it's value for 1 for 5ms after that set it to 10ms and this process should repeat continuously and it should start after the user activate accelerometer,
So by using this inside my if condition i can make sure it check the condition after 10ms and keep on checking for 5ms like this.........
if(output>10 && [[shared sharedInstance].var_x >1){
[[shared sharedInstance].counter++;
}
can anyone help me to code this timing function inside the global variable to set the variable value to 1 and 0 ? (
Upvotes: 0
Views: 345
Reputation: 17015
- (void)turnCheckOn {
doCheck = YES;
[self performSelector:@selector(turnCheckOff) withObject:nil afterDelay:0.005];
}
- (void)turnCheckOff {
doCheck = NO;
[self performSelector:@selector(turnCheckOn) withObject:nil afterDelay:0.010];
}
Then call turnCheckOn
once.
Upvotes: 1