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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to