Tuesday, March 6, 2012

Exception Handling in Objective C

So this is a brief code snippet explaining how to use the try catch to do exception handling


   @try
   {
      //Code on which you want to put the check
   }

   @catch (NSException *exception)
   {

      //This finds out which kind of exception it is.
      NSLog(@"main: Caught %@: %@", [exception name], [exception reason]);

   }


   @finally
   {
      //This piece of code executes no matter whether an exception occured or not.

   }



1 comment: