I have an UIButton that the user must click on it 5 times in three seconds, im trying to implement a method for that, but im getting the correct result if the user clicked on the button 5 times in 3 seconds in a row, if the user clicked once and stopped for 2 seconds for example, the counter take the first click in the calculation.
in a short words, i need a method that detect the last five clicks and know if the clicks were in three second or not…
Here is my old code:
-(void)btnClicked{
counter++;
if (totalTime <=3 && counter==5) {
NSLog(@"My action");
// My action
}}
I know that my code is too simple, so that why i asked you pro’s
Try altering this example appropriately: