Home Iphone Objectivec Exception handling in Objective-C
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Exception handling in Objective-C

Advertisement
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

 

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: September 26, 2008

Related Tutorials

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

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com