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

Discussion in 'iOS Programming' started by jerrywickey, Jun 22, 2009.

  1. jerrywickey macrumors member

    Joined:
    Apr 16, 2009
    Location:
    Key West
    #1
    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
     
  2. Jeremy1026 macrumors 68020

    Jeremy1026

    Joined:
    Nov 3, 2007
    #2
    You'll first need to create a file path to your apps Document directory.
     
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
    I would suggest the use of NSUserDefaults instead. Easier to work with, IMHO.
     

Share This Page