Coding object version with non-keyed (un)archiver
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.