I'm trying to study the work of NSCoding. I successfully created a sample. Here's what I have done. I create a read button. here are the codes
- (IBAction)readBtn:(id)sender {
self.cars.name = @"honda";
self.cars.color = @"blue";
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self.cars];
[[NSUserDefaults standardUserDefaults] setObject:data forKey:@"cars"];
}
and I create another button for write
- (IBAction)writeBtn:(id)sender {
NSData *datas = [[NSUserDefaults standardUserDefaults] objectForKey:@"cars"];
NSArray *books = [NSKeyedUnarchiver unarchiveObjectWithData:datas];
NSLog(@"array %@",books);
}
When I click the write button. why is it the output of my array is like this
array <Car: 0x7ff65bc44e50>
not the value of honda and blue.