Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Sergio10

macrumors regular
Original poster
Oct 3, 2007
137
0
Hi,

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

Thank you.
 
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?
 
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 alloc] init];
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:


How to read it correctly?

Thank you.
 
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.