On Mon, Oct 26, 2009 at 12:57 PM, Dick Bridges
<dbrid...@codecomplete.com> wrote:
> IIUC, 
> http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Exceptions/Exceptions.html
>  is available to everyone and is not under NDA. It's the "Introduction to 
> Exception Programming Topics for Cocoa". As noted on this page, the first 
> article is titled "Exceptions and the Cocoa Frameworks" and "...describes 
> NSException objects and their general use with the Cocoa frameworks." The 
> page also contains a reference to the related CoreRecipes sample code. The 
> document applies to both iPhone OS and Mac OS X. (FWIW, I am believe that 
> exception handling is also used *->within<-* some or all of the core 
> frameworks.)

In fact, some frameworks are implemented in C++, and use exceptions in
a way more idiomatic in that language.

> When discussing the relative merits of exceptions and error codes, the 
> distinction between "expected" and "unexpected" errors (i.e., exceptions) 
> must be maintained. Apple's "Error Handling Programming Guide for Cocoa" does 
> an excellent job of describing "...the recommended way to communicate 
> *->expected<-* errors in Cocoa applications" (emphasis added).


Correct, which is why you don't want to use exceptions for things like
"File not Found", but rather for programmer mistakes like "Tried to
set string value of integer attribute."

> The original question from Squ Aire contained a reference to the option of 
> returning nil. It may well be that I misunderstood, but I interpreted that as 
> exception handling and not the communication of normal, expected errors.

It appears you have misunderstood.  The NSError paradigm involves
returning a sentinel value (most frequently NO and nil) and filling in
the outError parameter.  No exception is thrown in this case.

--Kyle Sluder
_______________________________________________

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