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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:18:00+00:00 2026-05-26T02:18:00+00:00

Possible Duplicate: Change the time interval of a Timer So I have a timer:

  • 0

Possible Duplicate:
Change the time interval of a Timer

So I have a timer:

timer=[NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(createNewImage) userInfo:nil repeats:YES];

And I would like that the timer decrease every ten seconds, that scheduledTimerWithTimeInterval goes to 1.5 after ten seconds then to 1.0 after 10 seconds… Is it possible to do this, and if it is possible, how can I do it?

  • 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-26T02:18:01+00:00Added an answer on May 26, 2026 at 2:18 am

    You don’t have to use several timers, all you have to do is add a variable to use for the time interval, then create a method that invalidates the timer, changes the variable and starts the timer again. For instance you could make a method that starts the timer.

    int iTimerInterval = 2;
    
    -(void) mTimerStart {
        timer = [NSTimer scheduledTimerWithTimeInterval:iTimerInterval target:self selector:@selector(createNewImage) userInfo:nil repeats:YES];
    }
    
    -(void) mTimerStop {
        [timer invalidate];
    
        iTimerInterval = iTimerInterval + 5;
    
        [self mTimerStart];
    }
    

    This would be the simple way to decrease the timer interval and keep the timer going, but I would personally prefer using the one below, because it makes sure that the timer has only ran once, that way it will not duplicate the instance, forcing your app to become glitchy and it also makes things easier for you.

    int iTimerInterval = 2;
    int iTimerIncrementAmount = 5;
    int iTimerCount;
    int iTimerChange = 10; //Variable to change the timer after the amount of time
    bool bTimerRunning = FALSE;
    
    -(void) mTimerToggle:(BOOL)bTimerShouldRun {
        if (bTimerShouldRun == TRUE) {
            if (bTimerRunning == FALSE) {
                timer = [NSTimer scheduledTimerWithTimeInterval:iTimerInterval target:self selector:@selector(mCreateNewImage) userInfo:nil repeats:YES];
                bTimerRunning = TRUE;
            }
        } else if (bTimerShouldRun == FALSE) {
            if (bTimerRunning == TRUE) {
                [timer invalidate];
                bTimerRunning = FALSE;
            }
        }
    }
    
    -(void) mCreateNewImage {
        //Your Code Goes Here
    
        if (iTimerCount % iTimerChange == 0) { //10 Second Increments
            iTimerInterval = iTimerInterval + iTimerIncrementAmount; //Increments by Variable's amount
    
            [self mTimerToggle:FALSE]; //Stops Timer
            [self mTimerToggle:TRUE]; //Starts Timer
        }
    
        iTimerCount ++;
    }
    
    -(void) mYourMethodThatStartsTimer {
        [self mTimerToggle:TRUE];
    }
    

    I didn’t finish all of the coding, but this is most of what you will need. Just change a few things and you’ll be good to go!

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

Sidebar

Related Questions

Possible Duplicate: Change the Target Framework for all my projects in a Visual Studio
Possible Duplicate: How to change the href for a hyperlink using jQuery I have
Possible Duplicate: PHP/MySQL - Format date/time I have input field (name:day1 and varchar) to
Possible Duplicate: How to change the href for a hyperlink using jQuery I have
Possible Duplicate: Can we change the device time using an application? is that possible
Possible Duplicate: How to change format of date/time? In my program I'm making an
Possible Duplicate: Change CSS Dynamically I need to change the height of a div
Possible Duplicate: Can you animate a height change on a UITableViewCell when selected? This
Possible Duplicate: In PHP, how do you change the key of an array element?
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have

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.