Re: NSUnarchiver question
Re: NSUnarchiver question
- Subject: Re: NSUnarchiver question
- From: Raphael Sebbe <email@hidden>
- Date: Tue, 2 Oct 2001 10:33:09 +0200
Actually, there is versioning support in NSArchiver. You set the class
version using :
+ (void)initialize
{
if(self == [MyClass class])
{
// v1 -> feature added
[self setVersion:1];
}
}
Then implement NSCoding protocol like this
-initWithCoder: coder
{
int version = [coder versionForClassNamed:NSStringFromClass(MyClass)];
[super initWithCoder:coder];
if(version >= 1)
{
// decode feature
}
else
{
// init feature
}
return self;
}
Raphael
On Tuesday, October 2, 2001, at 09:21 AM, Alex Rice wrote:
-initWithCoder: coder
{
// in a class deep within the object graph &
// in a galaxy far far away
// document features added after document version 1.0
NS_DURING
// v1.1 feature:
[coder decodeValueOfObjCType:@encode(typeof(feature)) at:&(feature)];
NS_HANDLER
feature = MyDefault;
NSLog(@"failed to read feature");
[coder rollback]; //?
NS_ENDHANDLER
// now the next object in the graph can be safely initWithCoder'd
}