views:

152

answers:

2

Example: If I used this, where does the iPhone store the file?

if (![NSKeyedArchiver archiveRootObject:your_object toFile:@"filename.plist"])
   // save failed.

On my mac the filename.plist goes to Macintosh HD directly. No folder. Also, the NSKeyedArchiver doesn't seem to ask for a path, just for a file name. Strange or not?

And how's that file backed up with iTunes?

+1  A: 

The proper location to store the files is the documents folder:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
Diederik Hoogenboom
+1  A: 

archiveRootObject:toFile:
So you should pass it a path instead of just a filename. Otherwise NSKeyedArchiver will assume you want to store it in the root of the devices hard disk.
To make sure things get backed up by iTunes you'd need to save your data in the documents folder, done like Diederik Hoogenboom showed you already. Have a look at this guide.

bddckr