hotpaw2
hotpaw2

Reputation: 70703

iphone relative uptime?

Is there an API accessible timer on the iPhone that does not increment when the device is sleeping?

Upvotes: 1

Views: 433

Answers (2)

Biga
Biga

Reputation: 571

mach_absolute_timer() seems to not increment while sleeping.

Upvotes: 1

Aurum Aquila
Aurum Aquila

Reputation: 9126

Have you tried just setting up your methods like this:

-(void)someMethod{
    //Whatever code you wanted to run
    [self performSelector:@selector(someMethod) withObject:nil afterDelay:1.0];
}

I would assume that this doesn't execute when the device is sleeping. You could of course invalidate all your timers in the appDelegate's applicationWillEnterBackground method, then re-enable them when you resume.

Good luck,

Zane

Upvotes: 0

Related Questions