views:

194

answers:

3

I noticed that when building then running viewDidLoad only gets called once. If you press the home button and re-enter the application, viewDidLoad does not execute again.

Another thing I noticed is that when you re-enter an application it starts off right where you left off.

Is this the same behavior as in older SDKs? Does this mean that when the home button is pressed the application did not really exit?

+3  A: 

One difference with iOS4.0 is that if you press the home button your app might not necessarily terminate. The default setting is that they that will still be loaded in memory. This is the new 'multi-tasking' feature of iOS4.0. Turn it off and your app should be loaded every time.

UIApplicationExitsOnSuspend is the key for your plist to enable/disable background running.

willcodejavaforfood
Does the app keep running in the background or does it get paused and resumed?
awakeFromNib
Thanks, this is great for testing data persistence.
Ziggamorph
+1  A: 

With new iOS 4, multitasking arrived on iPhone and iPod Touch...
For this, when you are debugging or developing an application with the iPhone Simulator, if you press the home button, your app go in background or multitasking. Than Xcode believe that your app is still in use.

For recalling viewDidLoad method, you must completely exit from your app by pressing twice home button then hold down your app in the multitasking bar and tapping on the X.

Matthew
+2  A: 

When you press the home button, debugging is terminated and therefore you will not see anything from NSLog in the debugger console on any version of the SDK. You can try this by putting an NSLog in viewDidAppear:, which should get called even if the app is still running in the background in iOS 4, but doesn't

Felixs