iphone - problem with user defaults when saving a game... (int array) -
I have a problem in saving something and officially out of ideas. What I want to do, is an integer in userDefaults The array saves, then when this array is loading and restarts the game from this last point.
What I do is that every time my ARI logic saves the actual game position in an array -> so far that it works fine, the array is saved and when I saved the array I read it, so it feels ok ... okay in fact it has saved the right array!
Now I am restarting the game. I used to check for a bool variable that I also saved if the game was interrupted out of the system works fine.
Now the part of the trick is. I read the array from userDefaults and WOHOOO! I got a little different array then I saved! I really can not understand why: (
Good: Now Code:
What do I do to save the board here:
NSData * Data = [NSData DataWithbites: & amp; BoardToV length: sizeof (boardToSave)]; [userDefaults Data for Data: @ "MB_boardSave"];
And here's how I Return data when starting the board to get:
int loadBoard [8] [8] = {0}; NSData * data = [user default objectfire: @ "MB_boardSave"]; Memcpy (and loadboard, Data.bytes, data.length);
Again ... the one that's running is correct, which is not coming out: (
No The suggestions will be much appreciated! If you think that there are better options then I am also open for alternative saving options!
thx
edit bug is that you memcpy
to and loadboard
. loadBoard
, because it is an indicator. The same goes for boardto saver
.
The strange thing is that it works (and does not crash) as you do.
Comments
Post a Comment