Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8684943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:26:04+00:00 2026-06-12T22:26:04+00:00

I have an UIButton that the user must click on it 5 times in

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:26:05+00:00Added an answer on June 12, 2026 at 10:26 pm

    Try altering this example appropriately:

    // somewhere in the initialization - counter is an int, timedOut is a BOOL
    counter = 0;
    timedOut = NO;
    
    - (void)buttonClicked:(UIButton *)btn
    {
        if ((++counter >= 5) && !timedOut) {
            NSLog(@"User clicked button 5 times within 3 secs");
    
            // for nitpickers
            timedOut = NO;
            counter = 0;
        }
    }
    
    // ...
    
    [NSTimer scheduledTimerWithTimeInterval:3.0
        target:self
        selector:@selector(timedOut)
        userInfo:nil
        repeats:NO
    ];
    
    - (void)timedOut
    {
        timedOut = YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIButton that I disable for a few seconds after the user
I have a method that accepts a sender and is called with a UIbutton.
I have a UIButton (a subclass of one, actually) that interacts with the user
I have a UIButton that i'd like the user to be able to drag
I have a custom UIButton that has the label Name. When the user clicks
I have a UIButton that when clicked starts searching for data. But while searching,
I have a UIButton that I create in my sub class ViewController, and add
I have a UIButton that should have 2 statuses - Play and Pause; i.e.
I have a UIButton that is created inside of each table cell. I want
I have a UIButton that performs an Action when it is touched down. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.