How to create and update data files?

Posts: 16
Joined: 2008.10
Post: #1
I've read through the documentation but don't see any real samples on how to create, open, write, and update files. I want to store my game data so that when a call comes through the game will save it's state and reload on resume. Can someone point me to a sample that shows how to do this? Or maybe reference material? I know how to do this in C++ and C# and even on the XBOX but am not sure how and where to create files on the iPhone.

Help would be much appreciated. Smile
Quote this message in a reply
⌘-R in Chief
Posts: 1,277
Joined: 2002.05
Post: #2
"Where" is pretty well covered in "File and Data Management" in the iPhone OS Programming Guide. It also covers a few methods of "how."

You can of course write data to a file in many different ways. If you want to write your own binary file, that can obviously different than simply writing a string, or a property list (like a dictionary or array). You can use the standard C library functions, the posix calls, or any of the methods in NSString, NSDictionary, NSArray, NSData, NSCoder subclasses, NSPropertyListSerialization. It depends on what you want to write.
Quote this message in a reply
Post Reply