Home Iphone Objectivec Exception handling in Objective-C



Exception handling in Objective-C
Posted on: September 26, 2008 at 12:00 AM
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.

Exception handling in Objective-C

     

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

 

Related Tags for Exception handling in Objective-C:
cobjective-cexceptionideobjectiomakeviportintidaisupportwritedetecthandleconditionietohandlingexceptionsemainitcanliceinasconditionsmntcajobjobjectiveproppsurnsusoatkishallivflaeaexceptandcodcodertssrithcondhatjeprndodeono


More Tutorials from this section

Ask Questions?    Discuss: Exception handling in Objective-C   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.