Creating a plist file programmatically
Asked Answered
C

2

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.

Concavoconcave answered 18/2, 2010 at 21:31 Comment(0)
I
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];
Infundibuliform answered 18/2, 2010 at 21:39 Comment(0)
C
1
 [myArray writeToFile:aFile atomically:YES];
Corkboard answered 18/2, 2010 at 21:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.