How To Add “Fast App Switching” To Your iPhone App in iOS 4

iPhones 4 and iOS 4 introduce Apple’s take on multitasking applications. We can now “freeze” or “background” our apps so that when the user quickly switches between apps, our’s will return in the same state we left it.

I had a little trouble getting this done, but in the end it’s REALLY easy.

4.0 introduces a new project property in the info.plist called UIApplicationExitsOnSuspend. The default value for this boolean property is false. All you may need to do is recompile your application and check it out on an iOS 4 device.

image

If you find it’s not working, confirm the SDK settings both at the project level and at the target level. Your base SDK should be 4.0, and your target SDK should be whatever your lowest target device is. Of course, lower versions of the OS that don’t support multitasking will simply ignore this setting.

Also make sure your SDK settings are consistent between the project and the target settings.

image

image

To take multitasking even further, there are additional methods available where we should put any code we want to execute when the app goes into the background or returns to an active state, such as:

- store/restore state
- start/stop background processes

Check out:

https://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html

application:didFinishLaunchingWithOptions
applicationDidBecomeActive
applicationWillResignActive
applicationDidEnterBackground
applicationWillEnterForeground
applicationWillTerminate


iPhonePermalink

Name:

Email:

Location:

URL:

Smileys

Remember my personal information

Notify me of follow-up comments?