• 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
Handling errors in -initWithCoder:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Handling errors in -initWithCoder:


  • Subject: Handling errors in -initWithCoder:
  • From: Graham Cox <email@hidden>
  • Date: Fri, 13 Mar 2009 15:05:40 +1100

Minor problem, I think, but I'd like to get some advice about the right way to approach this.

One of my classes can sometimes fail in -initWithCoder: - it relies on certain resources being available and if it doesn't get them, I thought I could follow the same pattern as -init and autorelease self and return nil. When I do this though I get an error from the dearchiver, like:

*** -[__NSPlaceholderDictionary initWithObjects:forKeys:]: number of objects (0) not equal to number of keys (298)

This prevents the remainder of the archive from loading, which I don't want.

What's a good way to handle this? I would prefer that my object isn't created at all if possible, but that the archive loads what it can. It's hard to handle this in the class that owns this, because it's just an array of objects.

I'm thinking I need some post-processing that goes through and weeds out certain flagged objects, but maybe there's a better way?

--Graham


_______________________________________________

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: Handling errors in -initWithCoder:
      • From: "Sean McBride" <email@hidden>
    • Re: Handling errors in -initWithCoder:
      • From: "A.M." <email@hidden>
    • Re: Handling errors in -initWithCoder:
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Getting the front process path
  • Next by Date: Re: Getting the front process path
  • Previous by thread: Re: Getting the front process path
  • Next by thread: Re: Handling errors in -initWithCoder:
  • Index(es):
    • Date
    • Thread