Re: Subclassing and Archiving/Unarchiving
Re: Subclassing and Archiving/Unarchiving
- Subject: Re: Subclassing and Archiving/Unarchiving
- From: Graham Cox <email@hidden>
- Date: Sun, 25 Sep 2016 22:36:39 +1000
> On 25 Sep 2016, at 8:12 PM, Dave <email@hidden> wrote:
>
> Is there any way that I can get the archiver to just select the Base Class and ignore the extra properties in the Subclass? Or is there a better way of doing this?
You mean the dearchiver.
It can have a delegate (NSKeyedUnarchiverDelegate, https://developer.apple.com/reference/foundation/nskeyedunarchiverdelegate?language=objc). It can be called when it encounters a class it doesn’t recognise, and the delegate can return a different class, for example the base class. It is given a list of the class hierarchy (as strings) so that it can do this easily.
There are also class methods for setting up class substitutions.
You could also add the extra information as a subobject within the base class, and simply ignore it when dearchiving.
—Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden