• 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
Coding object version with non-keyed (un)archiver
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Coding object version with non-keyed (un)archiver


  • Subject: Coding object version with non-keyed (un)archiver
  • From: Simon Bovet <email@hidden>
  • Date: Tue, 12 Aug 2003 00:38:15 +0200

I though that [MyClass version] would return the version of MyClass as it was when encoded... Actually, I need to use -[NSCoder versionForClassName:] insteed. Do I miss something? When then should [NSObject version] be used? Thanks for any help or comment on my code below.

NB: I do not use keyed archiver on purpose! They are much too slow when hundred of objects need to be encoded...


@implementation MyClass

-(id)initWithCoder:(NSCoder *)inCoder
{
if (self = [super init]) {
member = [inCoder decodeObject];
if ([inCoder versionForClassName:@"MyClass"] > 0) // and *not* if ([MyClass version] > 0) !?!
newMember = [inCoder decodeObject];
}
return self;
}

-(void)encodeWithCoder:(NSCoder *)inCoder
{
[MyClass setVersion:1];

[inCoder encodeObject:member];
if ([MyClass version] > 0)
[inCoder encodeObject:newMember];
}

@end
_______________________________________________
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.

  • Follow-Ups:
    • Re: Coding object version with non-keyed (un)archiver
      • From: Scott Anguish <email@hidden>
  • Prev by Date: Encoding/decoding a class
  • Next by Date: Re: Message number 3
  • Previous by thread: Encoding/decoding a class
  • Next by thread: Re: Coding object version with non-keyed (un)archiver
  • Index(es):
    • Date
    • Thread