> On Jun 16, 2014, at 13:36 , Trygve Inda <cocoa...@xericdesign.com> wrote: > >> In the later method, if the encoded object does not contain kValueCKey, the >> object created will still have the correct default value for valueC (9). > > It won’t, because you assigned nil to valueC *after* it’s set to the default. > > Personally, I’d be inclined to have initWithCoder call super, because in more > complicated examples the logic tends to be quite different. If you have common > initialization (such as the initial setting of defaults), put them in a > private method that both initializers call. >
You're right. I wrote that right before nap time. :-) I guess the only way to prevent this is to check to see if [coder decodeObjectForKey:kValueAKey] returns non-nil before assigning it to valueA. Trygve _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com