Re: NSCoding of custom object instance variables (solved!)
Re: NSCoding of custom object instance variables (solved!)
- Subject: Re: NSCoding of custom object instance variables (solved!)
- From: Rick Hoge <email@hidden>
- Date: Tue, 13 Jul 2004 23:30:01 -0400
I'd have thought the last line of code would result in srcDocument's
encodeWithCoder method getting run, but logging messages (or lack of
them) indicate that it is not being used. The document subclass
_does_ have a replacementObjectForPortCoder: method - maybe this is
the problem?
Here was the problem - I had the following method in both the parent
object (the one actually passed as a parameter to the DO) and the
child. In the child, [encoder isByCopy] was NO so I was getting the
unwanted replacement object from the superclass.
-(id)replacementObjectForPortCoder:(NSPortCoder *)encoder {
if ([encoder isBycopy]) return self;
return [super replacementObjectForPortCoder:encoder];
}
Modifying this method so that it returns self for the child document
classes made everything work.
Rick
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.