---
title: "Throwing an Exception in Objective-C"  
description: "Throwing an Exception in Objective-C"  
author: "Anonymous User"  
published: 2015-10-23  
updated: 2015-10-23  
canonical: https://www.mindstick.com/forum/33526/throwing-an-exception-in-objective-c  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# Throwing an Exception in Objective-C

I was [learning](https://www.mindstick.com/articles/126221/instructional-design-for-elearning-why-it-is-so-important) Objective-C and [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to create [apps](https://www.mindstick.com/articles/12842/6-apps-for-writers-that-are-actually-worth-downloading), but some times I [am getting](https://www.mindstick.com/forum/34179/i-am-getting-error-while-assigning-the-data-to-the-array-list) exceptions in my code.

Can [anyone tell me](https://www.mindstick.com/interview/23033/can-anyone-tell-me-about-hadoop-toolbox) the best way to [handle exceptions](https://www.mindstick.com/forum/159234/how-do-you-handle-exceptions-using-the-try-catch-block-in-java) in iOS.

## Replies

### Reply by Tarun Kumar

I will prefer NSException class to [handle](https://www.mindstick.com/articles/311004/suede-skillet-handle-cover) [exceptions](https://www.mindstick.com/interview/22871/define-predifined-generic-exceptions) in our program,\
I use [NSException raise:format:] as follows:

```
[NSException raise:@"Invalid value" format:@"Code %d is invalid", str];
```


---

Original Source: https://www.mindstick.com/forum/33526/throwing-an-exception-in-objective-c

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
