I want to save My Data Type temporarily in NSUserDefault. this data is later backtracked.
I tried to execute the following code.
MyObject *myObject = [[MyObject alloc] init]; [[NSUserDefaults standardUserDefaults] setObject:myObject forKey:@"kMyObject"];
but the console will show me the following message.
-[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value '<MyObject: 0x4aadb0>' of class 'MyObject'. Note that dictionaries and arrays in property lists must also contain only property values.
I can ignore these messages and force pull them out of NSUserDefault.
MyObject *getObject = [[NSUserDefaults standardUserDefaults] objectForKey:@"kMyObject"];
but do not return the original data. (I checked NSLog, returns Null.)
How to solve this problem? I prefer to keep only NSUserDefaults. I am not recommended to use CoreData.
user1525048
source share