Re: What state does an iOS app retain after being quit that causes it to crash on relaunch?
Re: What state does an iOS app retain after being quit that causes it to crash on relaunch?
- Subject: Re: What state does an iOS app retain after being quit that causes it to crash on relaunch?
- From: Conrad Shultz <email@hidden>
- Date: Tue, 10 May 2011 21:14:44 -0700
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 5/10/11 8:44 PM, G S wrote:
> We have a network-dependent app that will suffer from lengthy delays if
> connectivity is poor. We've found that if the user quits the app during a
> long network activity, the app will often crash upon its next launch.
>
> Why? It shouldn't be retaining any state between launches.
On iOS >= 4 this is not true. Even without explicitly opting into
multitasking (e.g. by declaring background operations, termination
handlers, etc.), on "quit" apps are not terminated but suspended (i.e.
state is kept in memory and restored when the app is relaunched). The
app may still be terminated either by the user force-quitting it
(probably only power users do this) or if the operating system needs to
free up memory by purging apps that have been suspended for a while.
Your app delegate gets various notifications/messages that it can use to
perform appropriate actions at the various points in the life cycle, and
it sounds like you might need to do this. These are discussed in detail
in the section "The Application Life Cycle" at
http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/CoreApplication/CoreApplication.html.
In particular, you may want to examine:
–applicationDidEnterBackground:
–applicationWillEnterForeground:
–applicationWillTerminate:
Also note that, depending on what you are trying to do, it may make
sense to do some network actions as a background task that will continue
(for a time) even after the app is suspended; look into UIApplication's
- -beginBackgroundTaskWithExpirationHandler: method if you want to go down
this road.
- --
Conrad Shultz
Synthetiq Solutions
www.synthetiqsolutions.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFNyg00aOlrz5+0JdURAttpAJ92CfUEZggLr4JccnXlrryn1s0glwCffDvS
mgK1i7Zb1Ga0Mx+Pnf3mnLs=
=eFUl
-----END PGP SIGNATURE-----
_______________________________________________
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