Re: NSArchiver and NSKeyedArchiver
Re: NSArchiver and NSKeyedArchiver
- Subject: Re: NSArchiver and NSKeyedArchiver
- From: Mike Abdullah <email@hidden>
- Date: Mon, 22 Sep 2008 11:06:18 +0100
Your archiving code could do it's own check for -[coder
allowsKeyedCoding] and log/raise an exception if not.
On 22 Sep 2008, at 04:21, D.K. Johnston wrote:
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
_______________________________________________
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