In encodeWithCoder:...[encoder encodeFloat:self.weightInLbs forKey:WeightInLbsKey];...should be...[encoder encodeFloat:self.weightInLbs forKey:WeightKey];...and in initWithCoder:..._weightInLbs = [decoder decodeFloatForKey:WeightInLbsKey];...should be..._weightInLbs = [decoder decodeFloatForKey:WeightKey];...and also in initWithCoder:..._date = [[decoder decodeObjectForKey:DateKey] retain];...should be..._date = [decoder decodeObjectForKey:DateKey];And references to WeightInLbsKey within the text should be WeightKey.
[encoder encodeFloat:self.weightInLbs forKey:WeightInLbsKey];
[encoder encodeFloat:self.weightInLbs forKey:WeightKey];
_weightInLbs = [decoder decodeFloatForKey:WeightInLbsKey];
_weightInLbs = [decoder decodeFloatForKey:WeightKey];
_date = [[decoder decodeObjectForKey:DateKey] retain];
_date = [decoder decodeObjectForKey:DateKey];
(Also, the default declaration in the NSCoding protocol header semantically uses the ver "aCoder" vs "encoder" and "aDecoder" vs. "decoder".)
Thanks Scott. I added them to the errata. Let me know if you find anything else. I really appreciate all the comments.
In encodeWithCoder:...
[encoder encodeFloat:self.weightInLbs forKey:WeightInLbsKey];
...should be...
[encoder encodeFloat:self.weightInLbs forKey:WeightKey];
...and in initWithCoder:...
_weightInLbs = [decoder decodeFloatForKey:WeightInLbsKey];
...should be...
_weightInLbs = [decoder decodeFloatForKey:WeightKey];
...and also in initWithCoder:...
_date = [[decoder decodeObjectForKey:DateKey] retain];
...should be...
_date = [decoder decodeObjectForKey:DateKey];
And references to WeightInLbsKey within the text should be WeightKey.
(Also, the default declaration in the NSCoding protocol header semantically uses the ver "aCoder" vs "encoder" and "aDecoder" vs. "decoder".)