Warning: applicationWillTerminate: not called on multitasking devices

Forums Programming iPhone SDK / UIKit / Objective-C / Xcode Warning: applicationWillTerminate: not called on multitasking devices

This topic contains 8 replies, has 5 voices, and was last updated by  PJX 3 years, 6 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
Author Posts
Author Posts
June 24, 2010 at 10:23 pm #222703

crmagicxxx
Participant
@crmagicxxx

Just to warn you all that applicationWillTerminate: will not be called on multitasking devices if app is suspended and then killed via the multitasking UI. According to Apple: “apps are not aware of any transitions into or out-of the suspended state”. So if you’re saving anything inside applicationWillTerminate: you better do it in applicationWillResignActive: also.

Best

Edit:

Reference – https://devforums.apple.com/message/239897#239897

June 24, 2010 at 11:26 pm #288079

jyoung
Participant
@jyoung

Alternatively, from Apple documentation, “you can explicitly opt out of the background execution model by adding the UIApplicationExitsOnSuspend key to your application’s Info.plist file and setting its value to YES.”

June 24, 2010 at 11:32 pm #288080

crmagicxxx
Participant
@crmagicxxx

Yes you can, but I am sure users will adopt that “quasi multitasking” very soon and you’ll get bad reviews if your app goes away like that…

June 24, 2010 at 11:54 pm #288081

Codemattic
Moderator
@codemattic

thanks @crmagicxxx – I would of guessed that -applicationWillTerminate: would be called, it seems wrong that it doesnt, you *are* terminating. -applicationWillResignActive: it is then.

June 25, 2010 at 12:51 am #288082

jyoung
Participant
@jyoung

magic, you bring up a good point. I was going to disable my game from going into the background since it is a game..

“Opting out of background execution may be preferable for certain types of applications. Specifically, if coding for the background may require adding significant complexity to your application, terminating the application may be a simpler solution. Also, if your application consumes a large amount of memory, the system might need to terminate your application quickly anyway to make room for other applications. Thus, opting to terminate, instead of switch to the background, might yield the same results and save you development time and effort.”

But now I’m rethinking this. I guess I’ll have to get it on the device and see for myself.

I’d be interested to know what other developers think about suspending games in iOS4?

June 25, 2010 at 2:59 am #288083

Codemattic
Moderator
@codemattic

“I was going to disable my game from going into the background since it is a game..” if you do, please save your game state so when I restart your game it brings me back to where I was. Best thing short of multitasking.

June 25, 2010 at 4:30 am #288084

jyoung
Participant
@jyoung

@Codemattic done :)

I just don’t know if it’s worth keeping the entire app in memory in the background.

July 2, 2010 at 9:19 am #288085

jptsetung
Participant
@jptsetung

“Also, if your application consumes a large amount of memory, the system might need to terminate your application quickly anyway to make room for other applications.”

That means that you don’t risk anything to implement the background state with the director stopAnimation method.

October 3, 2010 at 12:51 am #288086

PJX
@pjx

I copied my state saving code from applicationWillTerminate to applicationDidEnterBackground and also added a multitaskingEnabled boolean so that I only call state saving in applicationDidEnterBackground. BECAUSE, there is one instance on a multitasking device where applicationWillTerminate is called: If the app is in the foreground and you power off the device. In that case, both applicationDidEnterBackground and applicationWillTerminate get called.

My question really is not about saving state, it’s about releasing Cocos2D: Where do we call ‘end’ on the CCDirector object? Is this creating a huge memory leak?

Some things about iOS really make no sense and this applicationWillTerminate thing is one of them.

Regards, Patrick

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.