Is it just me or does the debug version of the simulator not support writing out to the User Preference?
For Example
-(void) save {
NSUserDefaults *pref = [NSUserDefaults standardUserDefaults];
[pref setObject:[NSKeyedArchiver archivedDataWithRootObject:self] forKey:@"food"];
[pref synchronize];
}
-(void) load {
NSUserDefaults *pref = [NSUserDefaults standardUserDefaults];
NSData *dbObject = [pref objectForKey:@"food"];
if(dbObject != nil)
{
self = [[NSKeyedUnarchiver unarchiveObjectWithData:dbObject] retain];
}
[dbObject release];
}
Yes, I do have the proper initWithEncoder and encodeWithEncoder methods for the class. It compiles fine and seems to run through them just fine, except it never is able to reload the object from the key. Basically, dbObject is always returning nil, even though it saves properly.
If anyone has any other suggestions on how to store the data besides the user preferences, please let me know. I am open to all suggestions on how to store data for between sessions.