Re: Handling errors in -initWithCoder:
Re: Handling errors in -initWithCoder:
- Subject: Re: Handling errors in -initWithCoder:
- From: "A.M." <email@hidden>
- Date: Fri, 13 Mar 2009 10:17:01 -0400
On Mar 13, 2009, at 12:05 AM, Graham Cox wrote:
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?
You could set some flag in initWithCoder: and then return nil from
awakeAfterUsingCoder: when the flag is set.
Cheers,
M
_______________________________________________
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