Re: NSEncoder question
Re: NSEncoder question
- Subject: Re: NSEncoder question
- From: "Erik M. Buck" <email@hidden>
- Date: Sat, 6 Oct 2001 08:53:11 -0500
If your class implements the NSCoding protocol and its super class does not,
then -initWithCoder: should be implemented to call the super class'
designated initializer. If the super class does conform to NSCoding
then -initWithCoder: should be implemented to call the super
class's -initWithCoder:.
NSObject does not conform to NSCoding. As it happens, the NSObject class'
designated initializer is the -init method. NSObject's -init does not do
anything and NSObject has no instance variables other than isa which is
initialized by +alloc in the Objective-C run-time. Although it is
technically not necessary to call NSObject's init method in the current
implementation, I suppose that could change some day. It could even change
due to +poseAsClass: in which init does something. For safety and
consistency, follow the rules and call the super class' designated
initializer even when subclassing NSObject.
Maybe the examples should be changed if they don't follow the rules.