Is it possible to save an integer array using NSUserDefaults on the iPhone? I have an array declared in my .h file as: int playfield[9][11]
that gets filled wi
From Apple's NSUserDefaults documentation:
A default’s value must be a property list, that is, an instance of (or for collections a combination of instances of): NSData, NSString, NSNumber, NSDate, NSArray, or NSDictionary.
This is why you are getting the pointer error.
You have several options (in order of recommended usage):
NSArray
of NSArray
s to store playField
in your application
int
, but fill an NSArray with numbers before saving to NSUserDefaults
.
NSArchiver
to convert between an array of integers and NSData
.