Unarchive consistency errors
Unarchive consistency errors
- Subject: Unarchive consistency errors
- From: Sam Thorne <email@hidden>
- Date: Sun, 25 Apr 2004 15:27:41 +0100
Hello,
I can't work out what the inconsistency might be in unarchiving.
My object inherits from NSObject so doesn't need to call [super
initWithCoder:], the objects are encoded and decoded in the same order,
why is this raising an inconsistency in unarchiving exception?
-(void)encodeWithCoder:(NSCoder *)coder
{
[coder encodeObject:myType]; // NSString
[coder encodeObject:name]; // NSString
[coder encodeObject:myPath]; // NSString
[coder encodeObject:codeView]; // NSMutableArray
[coder encodeObject:imagePreview]; // NSImage
[coder encodeObject:soundPreview]; // NSSound
}
-(id)initWithCoder:(NSCoder *)coder
{
if (self = [super init]){
[self setMyType:[coder decodeObject]];
[self setName:[coder decodeObject]];
[self setMyPath:[coder decodeObject]];
[self setCodeView:[coder decodeObject]];
[self setImagePreview:[coder decodeObject]];
[self setSoundPreview:[coder decodeObject]];
}
return self;
}
The only different from normal mutator I have is this:
-(void)setMyType:(NSString *)setType
{
id old = myType;
myType = [setType retain];
[old release];
if ([myType isEqualToString:@"code"]){
myIcon = [[NSImage imageNamed:@"codeIcon"] retain];
}else if([myType isEqualToString:@"graphic"]){
myIcon = [[NSImage imageNamed:@"image"] retain];
}else if([myType isEqualToString:@"sound"]){
myIcon = [[NSImage imageNamed:@"volume"] retain];
}
}
with an accessor that just returns myIcon.
Any clues?
Thanks!
--
Sam
So long, and thanks for all the fish.
_______________________________________________
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.