Read/Write data

Discussion in 'iOS Programming' started by Sergio10, Sep 29, 2009.

  1. Sergio10 macrumors regular

    Joined:
    Oct 3, 2007
    #1
    Hi,

    I need to save and load NSMutableArray data. How to implement it nicely?

    Thank you.
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    As per the documentation: writeToFile:atomically.

    Given such an obvious method name I have to ask: Did you even open the documentation and try to do something for yourself before asking? Or do you just expect others to do all the work for you?
     
  3. Sergio10 thread starter macrumors regular

    Joined:
    Oct 3, 2007
    #3
    Thanks for replying.

    I can't read data from the plist. I've read documentation and nothing found I need.
    Here is a code I developed:
    PHP:
    NSMutableArray all = [[NSMutableArray allocinit];
    all = [NSMutableArray arrayWithContentsOfFile:@"/Users/rock/Library/Application Support/iPhone Simulator/User/Applications/93213E00-A9A2-4441-8A37-C1A7DF7C7B8F/Documents/test.plist"];
    It returns "0". Here is a plist image:
    [​IMG]

    How to read it correctly?

    Thank you.
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    How did you come to that path? You should not be hardcoding it. Use NSSearchPathForDirectoriesInDomains to find the path to your apps sandboxed area and append the path of the file. Also check using NSFileManager that the file exists at the path first
     
  5. newlearner macrumors member

    newlearner

    Joined:
    Jul 30, 2009
    Location:
    india
    #5
    to get an idea about how to read from plist, have a look at this page.

    The tutorial describes loading content from a plist into a table.
     

Share This Page