PDA

View Full Version : Is [aString writeToFile: best way to save user data?




jerrywickey
Jun 22, 2009, 01:14 PM
In this app, I have a lot of user data that will be saved for the next time the pp is launched.

Is

[aString writeToFile: filename]

and

aString = [NSString stringWithContentsOfFile: filename]

the easiest way to save data?

In the simulator file filename ends up in the hard-drive's root directory. Where does it end up in the iPhone?

Does it matter where it ends up because the iPhone's "harddrive" can't actually be accessed by the user?

Where should I put the file?

Is there a function that returns a file path that is specific to the app?

Jerry



Jeremy1026
Jun 22, 2009, 01:23 PM
In this app, I have a lot of user data that will be saved for the next time the pp is launched.

Is

[aString writeToFile: filename]

and

aString = [NSString stringWithContentsOfFile: filename]

the easiest way to save data?

In the simulator file filename ends up in the hard-drive's root directory. Where does it end up in the iPhone?

Does it matter where it ends up because the iPhone's "harddrive" can't actually be accessed by the user?

Where should I put the file?

Is there a function that returns a file path that is specific to the app?

Jerry

You'll first need to create a file path to your apps Document directory.

dejo
Jun 22, 2009, 01:38 PM
I would suggest the use of NSUserDefaults instead. Easier to work with, IMHO.