10

this question is regarding xcode objective c and iphone development:

So I want to store an array in a new plist file and I know how to retrieve the file path and write the data into the file (at least I think I do) and all that jazz once the plist is created, but how do I actually create the plist file the first time the app is run or the first time I go to enter data into it? I want it to live in the documents folder of my app.

I'm assuming this is pretty simple I just can't seem to find documentation on it.


I ended up using NSKeyedValue there was a great tutorial here:

http://vimeo.com/1454094

I know technically this is not the answer to the question but it did solve my problem.

4

2 回答 2

8

To save:

NSMutableArray *array = [[NSMutableArray alloc] init];
[array writeToFile:[@"/path/to/file.plist"] atomically: TRUE];

To retrieve:

NSMutableArray *array = [[NSMutableArray arrayWithContentsOfFile:[@"/path/to/file.plist"]] retain];
于 2010-02-18T21:39:56.587 回答
1
 [myArray writeToFile:aFile atomically:YES];
于 2010-02-18T21:35:07.407 回答