August 2011
Intermediate to advanced
552 pages
23h 48m
English
Cocoa provides two exception-handling mechanisms similar to what C++ and Java offer. The older, “classic” way to handle exceptions is to wrap a body of code with a set of macros. The newer way, the “native” way, was introduced in Mac OS X 10.3 and adds language support for exceptions.
To handle exceptions, wrap your code in an NS_DURING clause. Any exceptional conditions will raise an exception, which can then be caught by an NS_HANDLER clause.
The way you work it is:
NS_DURING ... code that might throw an exception NS_HANDLER ... code to examine the exception and possibly handle it NS_ENDHANDLER
If any code between NS_DURING and NS_HANDLER raises an exception, execution immediately ...
Read now
Unlock full access