Hi, I understood that I just hate the new iOS "multitasking" (as developer and as user as well)
is there a way to really close the app when the home button is pressed?
thanks
MandarX
P.S. when NSUserDefaults are saved?
A fast, easy to use, free, and community supported 2D game engine
Hi, I understood that I just hate the new iOS "multitasking" (as developer and as user as well)
is there a way to really close the app when the home button is pressed?
thanks
MandarX
P.S. when NSUserDefaults are saved?
Yes, you can close the app, once closed, double click the home button, you get an extra menu on bottom of screen, it's the list of recent apps, scroll left / right, then tap for a second the icon, and you will be able to delete from there (no worries won't delete the app from the phone)
Anyway not sure what you are trying to do, but you can save automatically data when entering on background mode, using:
- (void)applicationDidEnterBackground:(UIApplication *)application
on your main delegate class.
>Yes, you can close the app, once closed, double click the home button[...]
Thanks I knew it, I want to close the app (as a developer) when the user presses the home button
is there a way to kill it?
>you can save automatically data when entering on background mode, using:
> - (void)applicationDidEnterBackground:(UIApplication *)application
I use the NSUserDefaults, but I noticed that data seem to be saved only when the user quits the app
I don't think you can kill the app programatically.
I don't think you can kill the app programatically.
This will kill the app instantly abort() or i think: [ [CCDirector sharedDirector] end]
sry for double post...there should be something like applicationWillEnterBackground :D
If you've searched on "disable multitasking" you'd find this:
http://www.cocos2d-iphone.org/forum/topic/7386
So, there are answers for all your questions in first 2 posts
1) Open your application's plist file.
2) Add the "Application does not run in background" property
3) Tick it.
thanks
this is what I was looking for!
@cocos2dbeginner, a SIGABRT is raised by the abort() function, so not sure is a good practice. And the director end only deallocates all resources, including the OpenGL view, don't think it kills the app.
@MandarX, just an opinion, wouldn't be better if you save your data on applicationDidEnterBackground rather than force to exit the app? Just telling cos some users like the multitasking functionality that allows them to close and reopen on exact same point. So unless you can manage to restore your game on same previous position, you could face bad reviews.
Yes maybe it's better, but I won't use it in a game!!
I'm not sure what you want to do, but If your problem is that the NSUserDefaults is saved only on applicationWillTerminate, then maybe you don't need to worry, if the app goes to background, and then resume, the NSUserDefaults values are still the same, maybe you don't need to save it, as if the app was never closed, if you see what I mean.
And if the app is killed for any reason while in the background (like SpringBoard cleanup apps cos low memory), maybe the applicationWillTerminate will be called (not 100% sure though), so your data will be saved.
Anyway, check the NSUserDefaults synchronize function:
http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html
synchronize
Writes any modifications to the persistent domains to disk and updates all unmodified persistent domains to what is on disk.
- (BOOL)synchronize
Return Value
YES if the data was saved successfully to disk, otherwise NO.
Discussion
Because this method is automatically invoked at periodic intervals, use this method only if you cannot wait for the automatic synchronization (for example, if your application is about to exit) or if you want to update the user defaults to what is on disk even though you have not made any changes.
As far as I understand, if you call the synchronize, all your data is written to disk.
@itlgames: I'm pretty sure I've read that if iOS jettisons an app in the background it will not usually receive the applicationWillTerminate call - it's just killed.
@MandarX:The usual behavior that most people expect from a game under the multitasking world is that the game will pause itself when it enters the background and save the current player data (in case the app gets killed in the background). The only exceptions to this that seem reasonable is on-lime multiplayer games (like Archetype) where you can't pick up where you left off, so the game is killed when it enters the background.
@crmagicxxx , @Dragyn Ok, my app will pause itself!
@itlgames thanks, I was worried about synchronization because I always thought (and noticed) that NSUserDefaults are saved just when the home button is pressed (the app was closed, before multitasking), but now I can see that "this method is automatically invoked at periodic intervals"
by the way: I made a language localization class that lets the app switch language regardless of the device language. Actually I save the NSUserDefaults, restart the scene and reload the right resources.
it works, I know it's easy to implement but I can share the code if someone thinks it can help.
MandarX
hi hactar,
is this legal?
1) Open your application's plist file.
2) Add the "Application does not run in background" property
3) Tick it.
apple will not reject this type of application? thank you
It is legal.
Fruit Ninja is doing it, for example.
HI, this solution not working for me,
the Application does not run in background" property = was not found on the list so I add something with !tick! possibility, then rename to Application does not run in background" property and tick it on.. but it still runs in background...
The name of the Boolean (thing with !thick!) you want to add is: UIApplicationExitsOnSuspend
And if you "tick" it, your game won't run in background.
You must log in to post.