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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:11:12+00:00 2026-05-21T18:11:12+00:00

reading a lot about how to prevent iphone goingto sleep while running my app

  • 0

reading a lot about how to prevent iphone goingto sleep while running my app I am very unhappy at the moment because nothing worked..

here I read about the idea to set up a timer for every 30 seconds to set the idleTimerDisabled to NO and then YES, but my objC isn’t that good yet. could anybody tell me how (and where)?

thnx!

edit:
here is the code I tried:

- (void)applicationDidFinishLaunching:(UIApplication *)application
{   
    [ super applicationDidFinishLaunching:application ];
    //application.idleTimerDisabled = NO;
    //application.idleTimerDisabled = YES;
    //[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
    [UIApplication sharedApplication].idleTimerDisabled = NO;
    [UIApplication sharedApplication].idleTimerDisabled = YES;


}

edit2: after that I tried to start a loop with:

-(void)_timerLoop
{
    // add this function up the top.  it's what will happen when the
    // timer goes off:
    NSLog(@"Your timer went off!!!");
}


/**
 * This is main kick off after the app inits, the views and Settings are setup here.
 */
- (void)applicationDidFinishLaunching:(UIApplication *)application
{   
    [ super applicationDidFinishLaunching:application ];
    //application.idleTimerDisabled = NO;
    //application.idleTimerDisabled = YES;
    //[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
    //[UIApplication sharedApplication].idleTimerDisabled = NO;
    //[UIApplication sharedApplication].idleTimerDisabled = YES;
    [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(_timerLoop) userInfo:nil repeats:YES];


}

edit3: you really can’t change accidentially downvotes? would be a nice chnage request to the stackoverflow system!

  • 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-21T18:11:13+00:00Added an answer on May 21, 2026 at 6:11 pm

    Regarding your question about using a timer:

    Here is how you make a timer go off (just once) in 30 seconds from now:

    -(void)_jump
    {
    // add this function up the top.  it's what will happen when the
    // timer goes off:
    NSLog(@"Your timer went off!!!");
    }
    ...
    // here's how to create the timer, which will go off in 30 seconds
    [NSTimer scheduledTimerWithTimeInterval:30.0
       target:self selector:@selector(_jump) userInfo:nil repeats:NO]
    

    If you want two different timers, after say 30 and then 60 seconds, just make two in the same way. Let me know if you need more help with timers!


    It couldn’t be easier. Just add this line:

    application.idleTimerDisabled = YES;
    

    Inside your “application didFinishLaunchingWithOptions” routine.

    You will find that routine inside your app delegate .m source code file.

    Be sure to add it BEFORE the “return YES;” statement – a common mistake! So, exactly like this:

    -(BOOL)application:(UIApplication *)application
                didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
        {
        // blah blah ...
    
        application.idleTimerDisabled = YES;
        return YES;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to flash and actionscript 3. I've been reading a lot about
I've been reading a lot about this problem but I get nothing that suggests
I have been reading a lot about this - I feel like I'm very
I've been reading a lot about Unit tests and Test Driven developemnt. Recently, I
I've been reading a lot about prepared statements and in everything I've read, no
I have been reading a lot about C++ casting and I am starting to
I've been reading a lot about how Scala and Erlang does lightweight threads and
Lately I have been reading a lot of blog topics about big sites(facebook, twitter,
I've been reading a ton about xml and learning a lot but I am
I've been reading a lot about python-way lately so my question is How to

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.