FileIO from the app’s sandbox

by

When you want the app to store data, for instance the players name, the score etc and have it available the next time the player goes on you have to store things in the app’s sandbox.

Somehow, this is a bit complicated.

I have divided the FILEIO files in two stages: The Filio for basics like

  • clearCache (clears all files)
  • getDirectory (give the names of the existing files)
  • get an file

then I have a header and source file for converting this stuff into properties of my objects and the other way around, getting my properties in a format which is acceptable for fileio.

You have to realize that for instances arrays written to the cache can contain only objects like NSSTring, and NSNumber. More complex, homemade objects cannot be stored in an NSArray for writing to file.Actually you write a NSString to memory, and what you get out, also is a NSString. These NSStrings are then converted to arrays of NSNumbers (if needed).

This is an example where you can see the directory and have a few buttons for writing and reading two files to the sandbox of an app. The image in the background is from Grungegolf!

write a file

Advertisement

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.