Re: initWithCoder: calling init in custom class

2014-06-16 Thread Scott Ribe
On Jun 16, 2014, at 4:24 PM, Trygve Inda wrote: > 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. Well, if you're not afraid of terse idioms and GCC extensions, you can avoid all the hooha

Re: initWithCoder: calling init in custom class

2014-06-16 Thread Trygve Inda
> On Jun 16, 2014, at 13:36 , Trygve Inda 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. > > Per

Re: initWithCoder: calling init in custom class

2014-06-16 Thread Quincey Morris
On Jun 16, 2014, at 13:36 , Trygve Inda 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 b

initWithCoder: calling init in custom class

2014-06-16 Thread Trygve Inda
I have a custom class: @interface MyClass : NSObject {} @property (nonatomic, retain) NSNumber* valueA; @property (nonatomic, retain) NSNumber* valueB; @property (nonatomic, retain) NSNumber* valueC; @end @implementation MyClass -(id)init { if (self = [super init]) { [self valueA