NSCodingとNSCopyのサンプルプログラム
コード下記:
– (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super init];
if (self) {
self.country = [aDecoder decodeObjectForKey:@"country"];
self.city = [aDecoder decodeObjectForKey:@"city"];
self.region = [aDecoder decodeObjectForKey:@"region"];
self.street = [aDecoder decodeObjectForKey:@"street"];
self.location = [aDecoder decodeObjectForKey:@"location"];
}
return self;
}
– (void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:_country forKey:@"country"];
[aCoder encodeObject:_city forKey:@"city"];
[aCoder encodeObject:_region forKey:@"region"];
[aCoder encodeObject:_street forKey:@"street"];
[aCoder encodeObject:_location forKey:@"location"];
}