Re: Sleep Notification
Re: Sleep Notification
- Subject: Re: Sleep Notification
- From: Matt Neuburg <email@hidden>
- Date: Tue, 15 Feb 2011 12:25:25 -0800
On Sat, 12 Feb 2011 13:01:28 -0600, Gordon Apple <email@hidden> said:
>If it exists, could somebody point me to notifiers for sleep/wake in iOS?
>
>I have a comm link that goes down with sleep. I would like to bring it up
>again on wake (in case the user forgot to disable sleep). I'm already doing
>this for applicationWillEnterForeground, but that doesn't work for sleep.
What is "sleep" in iOS? The user can lock the screen, but that might or might not cause the device to sleep, depending on a zillion other factors. Many things can continue happening in the background. The whole concept is a shaky one.
If your app is backgrounded, you'll be suspended (freeze-dried) and all your code will come to a complete stop, unless you take certain special measure that qualify you for prevention of this (e.g. you're producing background audio). In that case you'll get applicationWillEnterForeground when coming back to the front.
If the screen is locked and your app was in the background, it was already suspended and you're covered.
If the question is "How can I cover the case where the screen was locked and is now being unlocked and my app is *frontmost*", that is your app becoming *active*. Basically for long continuous activities you should pause when the app becomes inactive and resume when the app becomes active again. Indeed, you will also get the active notification when entering the foreground, so it is a very good all-around place to cover resuming from interruptions of any kind. m.
--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.apeth.net/matt/default.html#applescriptthings_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden