I’m going to start by trying to give you a short answer, because data storage is a really big topic.
First off, don’t think of the data in terms of complete lines, but rather individual cells in a spreadsheet. I mean, ultimately you do have to write the lines as complete strings, but don’t think like that; think of it like you are filling out an Excel spreadsheet. So then your data is a set of rows for each level, where the first column is the level number and the second number is the completion state:
1 true
2 false
3 true
Then when you load the data back in, chunk it up in the same way. The code from this thread is really useful for splitting up the data:
http://developer.anscamobile.com/forum/2011/01/19/suggestions-how-parse-string-12-2312-144-1
Then use the data to fill out tables in the code, by looping through all the data line by line and writing something like:
levels[data[1]] = data[2]
–
Now the long answer is, well, really long. To see just how big a can of worms this is, try looking up “xml” in a search engine.
Stuff like XML and JSON is all about organizing data. For example, XML for your level data could look like:
<completed><br> <level num="1">true</level><br> <level num="2">false</level><br> <level num="3">true</level><br></completed>
What’s the point of all that scaffolding? Well let’s say you also want to store the highscore:
<hscore>12345</hscore>
<completed><br> <level num="1">true</level><br> <level num="2">false</level><br> <level num="3">true</level><br></completed>
Well would you look at that, now it’s easy to tell what each row means.
ADDITION: What a coincidence, this thread just popped up
http://developer.anscamobile.com/forum/2011/01/26/could-use-example-writing-and-reading-file-variable [import]uid: 12108 topic_id: 5352 reply_id: 18740[/import]
