Handling errors in -initWithCoder:
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