数据存储,model 对象归档本地化

2018-03-01  本文已影响20人  seventhboy

-(void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:self.name forKey:@"name"];
[aCoder encodeInteger:self.age forKey:@"age"];
[aCoder encodeDouble:self.height forKey:@"height"];
[aCoder encodeFloat:self.weight forKey:@"weight"];
}
-(id)initWithCoder:(NSCoder *)aDecoder
{
if (self=[super init]) {
self.name=[aDecoder decodeObjectForKey:@"name"];
self.age=[aDecoder decodeIntegerForKey:@"age"];
self.height=[aDecoder decodeDoubleForKey:@"height"];
self.weight=[aDecoder decodeFloatForKey:@"weight"];
}
return self;
}

上一篇下一篇

猜你喜欢

热点阅读