Search
Rich's Mad Rants
Powered by Squarespace

Creating iOS 5 Apps Discussion > Page 296 - Errata: WeightInLbsKey does not exist, and a lingering retain call

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".)

December 28, 2011 | Unregistered CommenterScott

Thanks Scott. I added them to the errata. Let me know if you find anything else. I really appreciate all the comments.

December 29, 2011 | Registered CommenterRichard Warren