Saving the game state when pressing the Home button

Apprentice
Posts: 11
Joined: 2009.01
Post: #1
Hi! I'm porting a PocketPC game that makes use of the EDGELIB library to the iPhone (my first experience with a Mac platform). In PocketPC, the user can switch to another application and, when clicking again on its icon, the application restores itself automatically. Is there a similar thing on iPhone? Or should I write myself all the code that saves the application state before exiting?

Thanks in advance for your answers,

--Nacho
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #2
You have to write your state saving code yourself. There is a system in place to make that easy to do though, called NSUserDefaults.

[adding] Register for UIApplicationWillTerminateNotification so you can be notified when to save your state.
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #3
Or implement applicationWillTerminate: in your application delegate class.
Quote this message in a reply
Apprentice
Posts: 11
Joined: 2009.01
Post: #4
Hi! Sorry for my late reply.

Since I'm using the EDGELIB library, I think that all those things you mention are wrapped under the library's framework. Nonetheless, I've found out that the method OnExit gets called whenever the user presses the Home button, so I've placed my call to the save function in there.

Thanks for all your help!

--Nacho
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Game State Management Mattonaise 6 7,225 Apr 16, 2011 10:18 AM
Last Post: Mattonaise
  Saving context markhula 4 6,100 Mar 8, 2011 02:37 AM
Last Post: markhula
  saving/reading level data using plists aerospaceman 6 4,565 Nov 29, 2010 02:44 PM
Last Post: aerospaceman
  How do you create enums for state charts in ObjC? riruilo 7 7,001 Mar 27, 2010 11:50 PM
Last Post: AnotherJake
  Increase skill level button dunhill68 12 5,457 Jan 8, 2010 02:57 PM
Last Post: dunhill68