• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSArchiver and NSKeyedArchiver
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >NSArchiver and NSKeyedArchiver (From: "D.K. Johnston" <email@hidden>)

  • Prev by Date: [SOLVED] Did I find a NSScanner bug, or am I doing this all wrong?
  • Next by Date: Re: fullscreen quicktime across multiple monitors
  • Previous by thread: NSArchiver and NSKeyedArchiver
  • Next by thread: Re: NSArchiver and NSKeyedArchiver
  • Index(es):
    • Date
    • Thread