//storingPerson*person=//get the personNSData*encodedPerson=[NSKeyedArchiverarchivedDataWithRootObject:person];[[NSUserDefaultsstandardUserDefaults]setObject:myEncodedObjectforKey:@"encodedPersonKey"];//retrievingNSData*encodedPerson=[[NSUserDefaultsstandardUserDefaults]objectForKey:@"encodedPersonKey"];Person*person=(Person*)[NSKeyedUnarchiverunarchiveObjectWithData:encodedPerson];

By that, we already have 2 deserialization methods. Also, if we want to send the modified object back to the server,
we'll need to add one more serialization method, that'll convert it back to NSDictionary , and then to JSON.

NSDictionary only solution

The only trick here is that we provide an -toDictionary method. As we already have -initWithDictionary:, this means we can serialize/deserialize to and from JSON and NSUserdefaults.

NSDictionary*personFromJSON=//get the personPerson*person=[[Personalloc]initWithDictionary:personFromJSON];person.surname=@"modifiedSurname";[persontoDictionary];// dict - you can convert it back to JSON

Like this article? You may want to Tweet about it.
You can also shoot me an email, or visit me on Twitter / Github.