Objective-C provide exception handling to handle exceptional conditions so that
code can be easier to write, easy to detect exceptions in the code and easier to
maintain as well. To take support of exception handling make sure the -fobj-exceptions
flag is turned on.
These are four compiler directives that are used for exception handling-
1. @try: block of code that can throw an exception.
2. @catch: define block of code to handle exception thrown by try block, this is usually an NSException object.
3. @finally: defines a block of code that executed whether an exception is thrown or not.
4. @throw: once your program detects an exception, it must propagate the exception to code that handles it. This code is called the exception handler. This entire
process of propagating an exception is referred to as "throwing an exception?.
Figure: Flow of Exception handling in Objective-C
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: September 26, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles