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 906063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:19:24+00:00 2026-05-15T16:19:24+00:00

how to make timer counter zero in this particular code when I click on

  • 0

how to make timer counter zero in this particular code when I click on the reset button
the values must go to 00:00:00 and when i click on start button timer should be start from starting
please help out

code here
this in the .h file code

-(void)start
{
timer1 = [NSTimer scheduledTimerWithTimeInterval:(.01) target:self selector:@selector(timepassed) userInfo:nil repeats:YES];

}

this is in the .m file

-(void)timepassed
{

counter++;

     if (counter == 60)  { sec++; counter = 0; }
    if (sec == 60) { min++; sec = 0; }
    if (min == 60) { hr++; min = 0; }

NSString *l=[NSString stringWithFormat:@"%i:%i:%i",hr,min,sec];

[m setText:l];

}
  • 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-05-15T16:19:24+00:00Added an answer on May 15, 2026 at 4:19 pm

    If need a variable to control if timer is running or not, then your function would look like:

    -(void)timepassed 
    {
        if (isTimerRunning)
        {
            counter++;
    
            if (counter == 60)  { sec++; counter = 0; }
            if (sec == 60) { min++; sec = 0; }
            if (min == 60) { hr++; min = 0; }
        }
        NSString *l=[NSString stringWithFormat:@"%i:%i:%i",hr,min,sec];
    
        [m setText:l];
    }
    

    With “Start” and “Stop” buttons you would just change values of variable “isTimerRunning”.
    Action for button “Reset” should be set variables “sec”, “min”, “hr” to zero and if you would like to stop timer at the same time set “isTimerRunning” to no.

    Another thing that you should test in your application is accuracy, doing it like this (setting interval to 0.01 sec, and then updating counter) might be inaccurate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 545k
  • Answers 545k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think your method is probably fine. Capturing the form's… May 17, 2026 at 8:56 am
  • Editorial Team
    Editorial Team added an answer Are you sure the two values are exactly the same?… May 17, 2026 at 8:56 am
  • Editorial Team
    Editorial Team added an answer You need to pass values to error check. public void… May 17, 2026 at 8:55 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

How do make a zero placeholder for the counter? My thought was an if
This error is inexplicably occurring. Here is the code and output: timer.cpp: #include timer.h
I'm writing an app that will need to make use of Timer s, but
I seem to make this mistake every time I set up a new development
I make a lot of web applications and from time to time I need
You can change the connection string at run-time like this. You make the connection
How would I make a counter using Greensocks TweenMax or TweenLite? Does anyone understand
I am just trying to make a timer. I would like to use UIDatePickerModeCountDownTimer
Would NTFS allocation blocks of 16KB or 32KB make compile time faster in comparison
Every time I make a project I develop several generic routines/modules/libraries that I expect

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.