• 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: Why Don't Cocoa's (Un)Archiving Methods return Errors?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?


  • Subject: Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?
  • From: Martin Wierschin <email@hidden>
  • Date: Tue, 02 Aug 2011 12:45:50 -0700

>> When you unarchive one of those strings, code expecting an instance of UnencodableFoo will instead have an NSString, the use of which will likely throw exceptions, eg: when code calls -[UnencodableFoo fooThing]
>
> No, it's not likely if UnencodableFoo is *my* code, because I program defensively when dealing with input data such as an archive :)

To defend against your solution you'd have to test every decoded object in the graph with something like:

	if( ! [decodedObject isKindOfClass:[XXExpectedClass class]] ) ...

Otherwise you don't know if you just decoded one of those strings you silently substituted.

Hitting an exception at the time of archiving is much better- it identifies the problem immediately. If you're trying to archive something that can't be archived, you need to know and change your code (eg: write the missing encoding method, choose a different data representation, etc).

~Martin

_______________________________________________

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: 
 >Re: Why Don't Cocoa's (Un)Archiving Methods return Errors? (From: Martin Wierschin <email@hidden>)
 >Re: Why Don't Cocoa's (Un)Archiving Methods return Errors? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: ARC and Singletons
  • Next by Date: Accessory NSPanel vanishes on first click after app launches - Follow up
  • Previous by thread: Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?
  • Next by thread: Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?
  • Index(es):
    • Date
    • Thread