Re: What is the expected Cocoa API behavior in an incomplete object traversal?
Re: What is the expected Cocoa API behavior in an incomplete object traversal?
- Subject: Re: What is the expected Cocoa API behavior in an incomplete object traversal?
- From: Martin Wierschin <email@hidden>
- Date: Fri, 15 Oct 2010 16:48:27 -0700
Well, in a normal situation the array would contain conforming
objects. However, as it can happen once in a while, one can add an
object to an array thinking it's of one type when in fact it's
another.
When you say "one can add", do you mean that the user chooses these
objects in the GUI somehow? If so, I might recommend you disallow the
user from making such an errant choice in the first place. Think of
the Open panel: the application controls which files are selectable.
Or maybe if the user chooses objects of the wrong class, the operation
should be disabled in the GUI. Or do preflight checks that present an
explanation sheet allowing the user to cancel or just skip the non-
conforming objects. Your description so far is too vague to know
what's best, but presenting an NSError after the operation completes
doesn't sound like the best solution.
If you really mean that occasionally your code adds an object to an
array thinking it's another class, that sounds like a bug to me and
I'd throw an exception so you can fix it ASAP. Though in a non-debug
build I might choose to gracefully just skip the object and avoid the
exception, as you're doing now.
~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