views:

326

answers:

3

Hi all,

I am writing a very simple application, for the iPhone. Unfortunately I am really a newbie. What I am trying to do is to save data at the end of a user experience. This data is really simple, only string or int, or some array.

Later I want to be able to retrieve that data, therefore I also need an event ID (I suppose).

Could you please point out the best way, API or technology to achieve that, XML, plain text, serialization... ?

Many thanks Leonardo

+6  A: 

Use NSUserDefaults. Straight forward and easy to use. This will handle all File I/O for you, and takes only a couple lines of code.

MarkPowell
A: 

Me and my team created a simple class for this purpose which as Mark pointed out makes use of NSUserDefaults. Hopefully this helps you out...

http://getsetgames.com/2009/10/07/saving-and-loading-user-data-and-preferences/

Rob Segal
+1  A: 

NSUserDefaults is a good choice for small amounts of data.

If you need to manage something larger than a kilobyte or so, you might consider using the initWithContentsOfFile: methods of NSArray or NSDictionary to read in a .plist file. To write the file, use the writeToFile:atomically: methods. This file needs to go in your app's documents directory.

Frank Schmitt