profile for monkeydom at Stack Overflow, Q&A for professional and enthusiast programmers

cocoa-dom

coding bits I use, come across, like, hate, the whole shebang.

twitter | github | mastodon     rant-dom     rss | archive

Permalink
Home

The hidden complexity of iOS 4 Multitasking

Just a Quick list of what to keep in mind when designing your app with the new Fast App Switching in place:

  • the entry point of your app might be anywhere and data may have changed. Even built in Apps like the Photos app get that one wrong. Have the Photos app open. Make new pictures. Go back. Or worse: download and delete all the photos to iPhoto. Reopen the Photos app: crash.
  • if something goes wrong, the app doesn't automatically stop and restart when the user presses home. This might seem obvious, but if there are edge cases where you mess up your navigation controller hierarchy beyond repair that matters. This happens. The user needs to know how to kill your app in that case, and most don't. Be extra careful with that.
  • besides the fast app switching way you still need to keep state and position in the app on your own for your next restart. For old devices as well as for when you get killed somewhere along the way. So you still need to do that. Defacto things got more complex instead of easier. However, if you do it right you might also have a good chance of being a good iOS 3.x citizen.
  • if you listen to URLs or Push Notification you need to be prepared for getting them while already running. Worse: you need to detect this yourself using a combination of willEnterForeground and didBecomeActive, so you can handle things differently if you were active and not. Also in the URL case the possibility exists you get called twice. See @chockenberry
  • network connections and hosting die when you get suspended. Be sure to reopen your server if you e.g. provide web access or something similar.
  • your app might not restart for very long time periods, make sure you move important checks and tasks to willEnterForeground or didBecomeActive so they don't starve out.¬†

That's just a quick list of real world issues I encountered. I'm sure there a lots more subtleties and edge cases. Be prepared!

Update:

  • if you have settings you need to make sure that changing those on the fly does work. E.g. the settings change can hit you in any place in your app and you need to be prepared and act like it: update lists, query the NSUserDefaults without caching, etc.
  • if opening an URL/push notification means you jump to another location in your app, the code handing that opening needs to be able to dismiss any - and I mean any - currently showing UI and present itself. This can be a very tough one.

Update 2:

With all the issues involved, opting out by adding UIApplicationExitsOnSuspend with a boolean value of YES to your Info.plist might be the better option if your app has great pre-iOS4 behavior.