Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-06-2012, 11:52 AM   #1 (permalink)
Registered Member
 
Keys's Avatar
 
Join Date: Jun 2010
Location: Edinburgh, UK
Posts: 62
Keys is on a distinguished road
Default Stop NSTimer stopping when iphone is locked

Hi All,

I know this is probably an old issue however hoping with the new IOS 5 apple might have let us use nstimer when the phone is locked.

As far as i can tell / have read, the only way to get NSTimer to continue is to play a silent sound when the phone is locked.

This seems really inefficient and drains the battery life - so has Apple put a solution to this, or is this still the way forwards?!

Thanks!
Keys is offline   Reply With Quote
Old 02-06-2012, 11:57 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

What are you trying to accomplish by running a timer when the phone is locked?
smithdale87 is offline   Reply With Quote
Old 02-06-2012, 12:01 PM   #3 (permalink)
Registered Member
 
Keys's Avatar
 
Join Date: Jun 2010
Location: Edinburgh, UK
Posts: 62
Keys is on a distinguished road
Default

Quote:
Originally Posted by smithdale87 View Post
What are you trying to accomplish by running a timer when the phone is locked?
Im trying to let the user timer something while the phone is locked. Did consider using a timestamp when the timer is started, then an nstimer to compare the current time with the time stamp... but that also seems a long way round something that should be simple!
Keys is offline   Reply With Quote
Old 02-06-2012, 03:02 PM   #4 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

You're gonna have to do the timestamp way.

I'm sure there are some excellent reasons why timers are not kept running when your app is no longer in the foreground - e.g. battery life.

Edit: What I mean by "the timestamp way" is to save the current time when the app goes into the background. Then when the app becomes active again, take the time you saved, and now the current time, so you can adjust your timer accordingly.
smithdale87 is offline   Reply With Quote
Old 02-07-2012, 03:51 PM   #5 (permalink)
Registered Member
 
Keys's Avatar
 
Join Date: Jun 2010
Location: Edinburgh, UK
Posts: 62
Keys is on a distinguished road
Default

Quote:
Originally Posted by smithdale87 View Post
You're gonna have to do the timestamp way.

I'm sure there are some excellent reasons why timers are not kept running when your app is no longer in the foreground - e.g. battery life.

Edit: What I mean by "the timestamp way" is to save the current time when the app goes into the background. Then when the app becomes active again, take the time you saved, and now the current time, so you can adjust your timer accordingly.
Yeah I ended up doing that, thanks anyway!
Keys is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 403
17 members and 386 guests
Alex-alex, Apptronics RBC, dre, FrankWeller, gwelmarten, ipodphone, jeroenkeij, jleannex55, LunarMoon, MAMN84, n00b, pbart, reficul, Retouchable, Sami Gh, usernametaken, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,125
Posts: 402,910
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:17 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0