Help with encodeObject: forKey:
Help with encodeObject: forKey:
- Subject: Help with encodeObject: forKey:
- From: Ian Gillespie <email@hidden>
- Date: Mon, 2 Dec 2002 17:28:25 -0800
OK, I am about to release a new application which encodes instance
variables in a model class. Before I release it, I want to make sure
that there is backward (and forward) compatibility with saved files,
because I am sure in the future I will modify the model class and its
encoding and decoding methods. So, someone suggested I use the method
encodeObject:(id)anObject forKey:(NSString *)str
Here is my encode method:
-(void)encodeWithCoder:(NSCoder *)coder {
//name returns an NSString
[coder encodeObject: [self name] forKey:@"Name"];
//date returns an NSCalendarDate
[coder encodeObject: [self date] forKey:@"Date"];
}
Whenever I save, the first line of code in this method gives the
following error:
Exception raised during posting of notification. Ignored. exception:
*** -encodeObject:forKey: only defined for abstract class. Define
-[NSArchiver encodeObject:forKey:]!
I should say that my model class is a subclass of NSObject and in the
header I have this:
@interface MyModelClass : NSObject <NSCoding>
Note also that it works fine if I use encodeObject:(id)anObject , it
just throws the exception when I use the encodeObject forKey.
So, excuse my ignorance as a new Cocoa developer, but how do I "define"
NSArchiver encodeObject:forKey: ?
~Thanks
_______________________________________________
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.