On Jun 24, 2012, at 8:14 AM, Dennis wrote:

> What if you explicitly set your NSError variable's value to nil immediately 
> before using it? Wouldn't it be safe to trust in that case?

To expand on Roland's pithy "No":

* You call method A with an NSError** that points to a nil pointer.
* A calls B, passing in the same NSError**.
* B fails, and sets the error to point to an NSError object describing what 
failed.
* A looks at the error and recovers from it somehow (maybe it fixes the problem 
and calls B again, or maybe it calls C instead and C succeeds.)
* A returns YES because it succeeded.
* …but your error variable is still pointing to the error returned by B, even 
though it doesn't matter to you.

<sarc>But of course this system is so much easier than using catch/throw 
exceptions. That would be complicated.</sarc>

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

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

Reply via email to