Saving Application data?

Discussion in 'iOS Programming' started by psxp, Aug 18, 2008.

  1. psxp macrumors regular

    Joined:
    Jan 8, 2008
    #1
    Hi,

    I have read the online documentation at the the DevCentre, and also scoured the forums here and there for help.

    I seemed to have missed the concept of how to store/save application data to the iphone for use later.

    ie. I have the user key in some text fields, make some selections, pick a picture from the camera roll. I would like to save this data to a file so it can be read back into the application later. Would I use the NSData object and the underlying "save to file" method from it?

    any help, or pointers would be MUCH appreciated.

    thanks!
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    For application state (so as you can restore the UI to the same position as it was when the user last used it) I would simply store into NSUserDefaults unless it's a massive amount of data.
     
  3. psxp thread starter macrumors regular

    Joined:
    Jan 8, 2008
    #3
    lets just say 50 - 100 data objects.. each with 5 text fields consisting of say 200 chars max and one photo/image per object. So the file would be in the kilobytes in size, not megs, BUT the image is the problem - I was thinking of just saving the path to the image file in the camera roll if I cant save with the application data.

    What I am saying here, is that I dont need to use SQLLite do I? that would be over kill right??
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Sounds like more data that you should be saving in NSUserDefaults. Save it to the application specific area in whatever way you like (create a NSDictionary and save that for example) as described in the File and Data Management page of the Application Design Guidelines section of the iPhone OS Programming Guide.

    You might want to consider a few NSDictionaries if some of the data is going to be loaded and some not...
     
  5. psxp thread starter macrumors regular

    Joined:
    Jan 8, 2008
    #5
    Hey, thanks for the pointers. I will re-read the File and Datamangement chaper now.

    cheers.

    B
     

Share This Page