I'm confused about NSUserDefaults
on the iPhone.
I come from a C / asm background and the Objective-C stuff has been a learning experience.
I'm currently using NSUserDefaults
to store some strings (for the names in a highscore table). I want to start implementing a "Save Game" type feature so if the user gets a call or exits out of the game for a moment, they can come back to it.
To recover the game, I've got a couple of BOOL
flags, a couple of int
s to store some necessary variables, but I'm stuck at an array I need to store.
I have a 50 element array of unsigned char
s. I could move it to int
s if it would make things easier, but I'm just not seeing it.
To work with NSUserDefaults
I can setBool
(already doing that), setFloat
(again, already doing that), setInteger
, and setObject
.
Obviously I could declare keys for each element of the array and store them one by one with setInteger
but that's really kludgy. What's the best way to tackle this? Instead of an array of unsigned char
s, I somehow try to use an NSObject
? Are there any good tutorials on NSObject
s that I can read through to understand it better?