• 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: Jens Alfke <email@hidden>
  • Date: Sat, 30 Jul 2011 23:00:08 -0700

On Jul 30, 2011, at 10:21 PM, Jerry Krinock wrote:

> I don't think so, Jens.  "They" is Apple.  Apple has the source code for -initWithCoder: and -encodeWithCoder:.

No they don’t — not for the implementations of those methods in our own classes. Anyone implementing an archivable class has to create custom implementations of those methods. Apple has no idea what those methods look like, and most importantly, what other objects they might try to archive.

So consider you have an NSArray that contains a Foo object. Foo is some 3rd party class that implements NSCoding. The Foo object has a reference to an NSDictionary, one of whose keys is a Bar object. Bar isn’t archivable.

So now you call +isEncodable: with that array. The best Apple (aka the Foundation framework) can do is to find that your Foo object is going to be archived since it’s in the array. Without calling into -[Foo encodeWithCoder:] it can’t possibly tell that Foo is going to try to archive that array it has, which contains the unarchivable Bar object. But if it does call into Foo, it’s eventually going to find itself trying to archive the Bar object and have no way to signal failure short of throwing an exception.

—Jens_______________________________________________

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

  • Follow-Ups:
    • Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?
      • From: Jerry Krinock <email@hidden>
References: 
 >Re: Why Don't Cocoa's (Un)Archiving Methods return Errors? (From: Rainer Brockerhoff <email@hidden>)
 >Re: Why Don't Cocoa's (Un)Archiving Methods return Errors? (From: email@hidden)
 >Re: Why Don't Cocoa's (Un)Archiving Methods return Errors? (From: Gwynne Raskind <email@hidden>)
 >Re: Why Don't Cocoa's (Un)Archiving Methods return Errors? (From: Jerry Krinock <email@hidden>)
 >Re: Why Don't Cocoa's (Un)Archiving Methods return Errors? (From: Jens Alfke <email@hidden>)
 >Re: Why Don't Cocoa's (Un)Archiving Methods return Errors? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Why Don't Cocoa's (Un)Archiving Methods return Errors?
  • Next by Date: Re: Release build throw "unrecognized selector sent to instance" for a category method
  • 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