views:

266

answers:

1

I have a class MyClass. It has instance variables passedInVar1, passedInVar2, etc. whose values will be passed in from the object that requests the initialization. It also has instance variables decodedVar1, decodedVar2, etc. that will be decoded from an archive -- or set to a default value if there is no archive.

According to Apple,

When an object receives an initWithCoder: message, the object should first send a message to its superclass (if appropriate) to initialize inherited instance variables, and then it should decode and initialize its own instance variables.

But Apple also says that a class should have a single designated initializer.

What is the best way to deal with all of this?

+5  A: 
TechZen
Everything you wrote makes sense . . . but I'm still unclear how to deal with my situation. In particular, how do I pass values for some of my ivars in when initialization is happening via initWithCoder?
William Jockusch
See my edit above for details.
TechZen
The second line in the last example should be "if (self=[super initWithCoder:decoder]) {"
zaph
@zaph -- good catch
TechZen