• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSUnarchiver question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
}


  • Follow-Ups:
    • Re: NSUnarchiver question
      • From: Alex Rice <email@hidden>
References: 
 >NSUnarchiver question (From: Alex Rice <email@hidden>)

  • Prev by Date: NSUnarchiver question
  • Next by Date: Making TIFFs with transparency
  • Previous by thread: NSUnarchiver question
  • Next by thread: Re: NSUnarchiver question
  • Index(es):
    • Date
    • Thread