Hi, I have a question, in my game, i'd like to save my game status each time when a level finished. i have a dictionary, which holds all the values i need to store, and if a level has finished, i use [dictionary writeToFile atomically ] to store those values into a plist. but when i test the game, when the level finished, the program will be stuck, and the console says nothing.
Anyone has any idea?
save game status and schedule
(4 posts) (3 voices)-
Posted 2 years ago #
-
Where are you writing the file to? You will have write/read access to the user's documents directory.
NSArray *paths; paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); if ([paths count] > 0) { // use [paths objectAtIndex:0] as the path to write // your dictionary/plist out to ... } else { //something went wrong! }If thats not it - maybe it would help to give us some code examples of what you are doing.
Since its a dictionary - you could also save it as part of the app's preferences - read up on NSUserDefaults.Posted 2 years ago # -
NSUserDefaults is very simple to implement. I think somebody mentioned it was slow but I haven't noticed it much at all saving 20+ settings.
Posted 2 years ago # -
thanks for your reply, i have solved the problem by dividing the job into two pieces. now i just save my values into my dictionary in the scheduled function, and when the program terminated i save the dictionary to the plist.
NSUserDefaults works more or less the same.
thank you again!
greetings
Posted 2 years ago #
Reply
You must log in to post.