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 protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net

This email sent to [EMAIL PROTECTED]

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to