NSArchiver and NSKeyedArchiver
NSArchiver and NSKeyedArchiver
- Subject: NSArchiver and NSKeyedArchiver
- From: "D.K. Johnston" <email@hidden>
- Date: Sun, 21 Sep 2008 20:21:49 -0700
I wrote a class that conforms to the NSCoding protocol. I used
encodeObject:forKey and decodeObjectForKey: in the required methods.
By mistake I used NSArchiver to archive one of the class instances. It
compiled with no trouble; but then, not surprisingly, I got an
exception when I ran it:
*** Terminating app due to uncaught exception
'NSInvalidArgumentException'
reason: '*** -encodeObject:forKey: only defined for abstract class.
Define -[NSArchiver encodeObject:forKey:]!'
The fact that I should have used NSKeyedArchiver instead of NSArchiver
isn't obvious from the message. (At least it's not obvious to me.)
Can anything be done to ensure users of the class use NSKeyedArchiver,
besides putting a comment in the header file?
Thanks etc.
dkj
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden