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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:39:56+00:00 2026-05-26T03:39:56+00:00

I know that I should understand Apple’s documentation for NSTimer, but I don’t! I

  • 0

I know that I should understand Apple’s documentation for NSTimer, but I don’t! I have also read a lot of questions about it but can not find one that suites my case. Well here it is:

The user enter hour and minutes through textfields. I convert those to integers and display them in a “countDownLabel”.

  1. How can i make the count down to zero?
  2. It would be nice to show the seconds which is something that the user didn’t imported but i guess it will not be hard to show.
  3. How could somebody stop this procedure with a press of a UIButton?

I know that i am asking a lot…I would be really grateful if someone could help!

int intHourhs;
intHourhs=([textHours.text intValue]);
int intMinutes;
intMinutes=([textMinutes.text intValue]);
int *intSeconds;
intSeconds=0;

NSString *stringTotalTime=[[NSString alloc] initWithFormat:@"%.2i:%.2i:%.2i",intHourhs,intMinutes,intSeconds]; 
[countDownLabel setFont:[UIFont fontWithName:@"DBLCDTempBlack" size:45]];
countDownLabel.text=stringTotalTime;
  • 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-26T03:39:57+00:00Added an answer on May 26, 2026 at 3:39 am

    First you should calculate what your countdown time is, in seconds and put it in a instance variable (ivar)

    NSTimeInterval totalCountdownInterval;
    

    I think in order to keep good accuracy (NSTimer firing can be off by as much as 100ms and errors will add up) you should record the date at which the countdown started, and put it in another ivar:

    NSDate* startDate = [NSDate date];
    

    Then you can have a timer firing at regular (here 1 second) intervals calling a method on your class repeatedly

    NSTimer* timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkCountdown:) userInfo:nil repeats:YES];
    

    And in that method you check the elapsed time against the total countdown time and update the interface

    -(void) checkCountdown:(NSTimer*)_timer {
    
        NSTimeInterval elapsedTime = [[NSDate date] timeIntervalSinceDate:startDate];
    
        NSTimeInterval remainingTime = totalCountdownInterval - elapsedTime;
    
        if (remainingTime <= 0.0) {
            [_timer invalidate];
        }
    
        /* update the interface by converting remainingTime (which is in seconds)
           to seconds, minutes, hours */
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that I should put all the html elements in body tag, but
I know that I should have schema of a table before calling NewRow method
I know that a command line application should return 0 on success. But are
I don't understand it at all but NSTimer in my app definitely is running
I know that we should only create repositories for Aggregate Roots and not for
this is my first question here :) I know that I should not check
I know that most links should be left up to the end-user to decide
I know that c++ code should be compiled and linked by g++, not gcc.
I know that the following code should show and hide a tiny circular progress
I know that the reminder application should display a badge or sound or kind

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.