tags:

views:

1246

answers:

2

I have an app that works well on iPhone OS 3.0 or higher. How do I support fast app switching in it? It should work as is on iPhone OS 3.0 but support fast app switch on iOS 4.0.

Anupam

+6  A: 

Set the Base SDK to 4.0 and the Deployment Target to 3.0. Fast app switching should now work.

To make your app behave properly when it is in the background and make sure you save your state early enough, you have to read and follow the chapter about multitasking in the iPhone Application Programming Guide completely, especially Supporting Background State Transitions and Being a Responsible, Multitasking-Aware Application.

Ole Begemann
+7  A: 

There's a great session video from WWDC on this called 'Session 105 - Adopting Multitasking on iPhone OD, Part 1' that explains the flow of a process between the different foreground and background modes, as well as during which time you get app delegate calls, and more importantly, when not. I highly recommend it on top of the already mentioned documentation. It's free to registered developers.

The gist is that while iOS 4.0 does notify you when you go into a background running state, and you then have time to save your own state, you don't get notified when your app actually gets terminated, so once you briefly go into a background running state, you're advised to both save your state as well as shut down all unnecessary resource usage already. This will ensure that your app is less likely to completely be terminated, once memory starts running low, which iOS does automatically.

Another thing to consider is that while iOS 4.0 does do full state saving for you (assuming your app was recompiled/deployed for 4.0), this applies only to suspending already running apps. You still need to write your own implementation to restore an app to the point where the user left off, if it was suspended, eventually terminated entirely, and the user then relaunches it.

Joost Schuur