-2
\$\begingroup\$

I am developing my first app for iPhone, using C++ and some Objective C code to interface with ios sdk api. My app is obviously a game. I was wondering where to save the state of the player (in my case, i want to save something like the number and identification label of every level finished, the score made at a level, how many stars taken, how many hidden item discovered and so on). My idea is to create (if it does not exist yet) a temp directory somewhere (is there a c: drive?). The temp directory will be there till the disinstallation of the game. In the temp directory, i will save all the relevant info. Is this the right way to handle this situation?

Ps. I see the reason for the downvote. I forget to specify that my app needs to run on different systems (iphone, android and so on...). I would like to employ a more portable technique...

\$\endgroup\$
  • 3
    \$\begingroup\$ Duplicates: gamedev.stackexchange.com/questions/21367/… gamedev.stackexchange.com/questions/77/… \$\endgroup\$ – MichaelHouse Jul 12 '12 at 19:40
  • 1
    \$\begingroup\$ How will you run your objective C game on "Android and so on..."? If you were to figure that out, you can detect which operating system you're running on and take the action appropriate for that OS. See the duplicates linked for iOS, then when you get to "Android and so on..." you can search this site for those answers, as I'm sure those have been asked before as well. \$\endgroup\$ – MichaelHouse Jul 17 '12 at 23:35
0
\$\begingroup\$

there is no C: Drive in this Case, but in Objective-c you could use the DocumentDirectory of your application.

NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];

So you get the path to the Document directory of your app. In this directory you can save your files.

Edit: if someone downvote, please submit the reason in a comment.

\$\endgroup\$
  • \$\begingroup\$ No downvoters comments, upvoting... \$\endgroup\$ – Markus von Broady Oct 4 '12 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.