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

  • Home
  • SEARCH
  • 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 8403513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:21:52+00:00 2026-06-09T22:21:52+00:00

I develop Stop Watch Application. In my application, there are Two UIButtons , StartBtn

  • 0

I develop Stop Watch Application.
In my application, there are Two UIButtons , StartBtn and StopBtn, And also I use NSTimer.

Now, i want to start NSTimer when user click on StartBtn and also stop when your click on StopBtn.

I know that NSTimer is stopped by [MyTimerName invalidate]; method but I don’t know how to start NSTimer again?

  • 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-09T22:21:54+00:00Added an answer on June 9, 2026 at 10:21 pm

    The NSTimer class is a bit awkward to use; rather than separating the creation/destruction from the start/stop, it’s all rolled together. In other words the timer starts as soon as it’s created and stops as soon as it’s destroyed.

    You therefore need to use the existence of the NSTimer object as a flag to indicate if it’s running; something like this:

    // Private Methods
    @interface MyClass ()
    {
        NSTimer *_timer;
    }
    - (void)_timerFired:(NSTimer *)timer;
    @end
    
    @implementation MyClass
    
    - (IBAction)startTimer:(id)sender {
        if (!_timer) {
            _timer = [NSTimer scheduledTimerWithTimeInterval:1.0f
                                                      target:self
                                                    selector:@selector(_timerFired:)
                                                    userInfo:nil
                                                     repeats:YES];
        }
    }
    
    - (IBAction)stopTimer:(id)sender {
        if ([_timer isValid]) {
            [_timer invalidate];
        }
        _timer = nil;
    }
    
    - (void)_timerFired:(NSTimer *)timer {
        NSLog(@"ping");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to develop a windows application to start/stop and monitor status of
I want to develop a simple stop watch logic in android. On clicking a
I develop a simple Spring application which is my university task. There are 3
I want to develop a application which will continue to run in background for
I'm so desperate to use a vpn application. In this app there are some
I want to develop logging system in OSGI bundle which can write application errors
I develop a desktop application for use on Windows, and was wondering how I
I want to develop my application with a simple animation. I have used a
i have develop a eblast application The program is use to send a email
I develop an application, and, at a given moment, I start about 10000 threads

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.