Simulator vs iPhone
Ah. That’s the problem. I’ve been chasing a bug lately, it works fine in the sim but the feature doesn’t work on the iPhone. Turns out the simulator isn’t a perfect simulation. We all know about the obvious stuff: no GPS for example. But on application termination with iOS 4 there’s a little detail that can be important:An app exits on the simulator by first calling first applicationWillResignActive then calling applicationDidEnterBackground on the application’s delegate.But on the phone, we get first applicationDidEnterBackground, then applicationWillTerminate. In both cases this is when the home button is pressed. If you kill the app with the debugger then it’s just killed and none of these gets called at all.This isn’t a big deal till you’ve got some data that you want the app’s delegate to save when the app goes background or is quitting. This is also one of the behaviors that changes in iOS4 too with the advent of multitasking. Unfortunately the Apple docs on the application delegate don’t go into the order the delegate calls are made, nor the variations between the sim and phone.And, since the test phone is a 3G, it may behave differently on a multitasking phone like a 3GS or 4 model.Sometimes, testing is the only way to find out what really happens.