Home  >  Blog  >   iPhone  > 

Objective C – Exception handling In iPhone

Rating: 4

The exception handling mechanisms available to OBJECTIVE-C programs are effective ways of dealing with exceptional conditions. They decouple the detection and handling of these conditions and automate the propagation of the exception from the point of detection to the point of handling. As a result, your code can be much cleaner, easier to write correctly, and easier to maintain.

Looking for IOS Training? Mindmajix Offers Best IOS Developer Training With Industry Experts.

Exception Handling

An exception is generated at runtime and these are runtime, error, objective c language as an exception handling syntax similar to c++, java and here we use NS exception, NS error.
An exception is a special condition but interrupts the normal flow of execution objective c has four exception compiler directives. They are.


Try Black:-

try black holds code that can potentially throw an exception that is enclosed in a try block.


Int  x;
   Scan f (  “%d”,    &x);

Int y =  2/x;

Catch Block:-

 A catch block contains exception handling logic for exception throw in a try block. We can have multiple catch block for single try block.


 @  catch (NS argument exception * aex)
@catch(NS exception   *  ex)

Finally, block:-  

This block is optional and it contains a code for declaration of resources.




 NS exception classes the base class for all the exception-related classes.


By using throws, we can rise over our own exception.


Frequently Asked iPhone Interview Questions & Answers


Join our newsletter

Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!

Course Schedule
IOS Development TrainingJan 22 to Feb 06
IOS Development TrainingJan 24 to Feb 08
IOS Development TrainingJan 29 to Feb 13
IOS Development TrainingJan 31 to Feb 15
Last updated: 02 Mar 2021
About Author
Remy Sharp
Ruchitha Geebu

I am Ruchitha, working as a content writer for MindMajix technologies. My writings focus on the latest technical software, tutorials, and innovations. I am also into research about AI and Neuromarketing. I am a media post-graduate from BCU – Birmingham, UK. Before, my writings focused on business articles on digital marketing and social media. You can connect with me on LinkedIn.

Recommended Courses

1 / 15