Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8615313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:20:49+00:00 2026-06-12T05:20:49+00:00

I read Apple’s recommendation on exception usage and NSError usage: Also, I read several

  • 0

I read Apple’s recommendation on exception usage and NSError usage:

Also, I read several similar stack overflow questions which discuss whether to use or not exception.

Exception Handeling in iOS

Using exceptions in Objective-C

Objective-C Exceptions

I am trying to figure out pros and cons of usage exception as error notification/handling method in iOS (Frankly, I am no satisfied with Apple’s sentence (it says what to do, but it doesn’t say why we should do it):

You should reserve the use of exceptions for programming or
unexpected runtime errors such as out-of-bounds collection access,
attempts to mutate immutable objects, sending an invalid message, and
losing the connection to the window server. You usually take care of
these sorts of errors with exceptions when an application is being
created rather than at runtime.

Exception usage pros:

  • It doesn’t require to modify all intermediate code between error generating code and error handling code

  • It doesn’t pollute arguments and return values for methods

Cons:

  • For all manually managed memory code we will have to be extra careful (we will need to wrap it in autoreleasing objects to make sure that resources are released).

  • We need to be careful with the border between our code and framework. If our exceptions leave our code, we could be in trouble (because frameworks may manually manage memory)

Did I miss anything? Are there additional cons/pros?

It looks like exceptions should be fine for library like code (when we have quite big amount of tightly packaged code, which doesn’t communicate a lot with external systems/frameworks. And it looks like exception are hard to use for the code which actively interacts with other frameworks.

Does your experience prove this theory?

I appreciate any additional info on this subject.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:20:50+00:00Added an answer on June 12, 2026 at 5:20 am

    tl;dr Exceptions should be used for fatal/non-recoverable/programmer error(s) only. Attempting to use them a la Java or other exceptions-are-recoverable environments will result in code that is more fragile, harder to maintain, and difficult to refactor while also limiting your ability to leverage system frameworks.


    Con: If you use exceptions for flow control and/or recoverable errors in your code, your code will be, by design, different from Apple’s design patterns.

    End result?

    • You can’t use Apple’s APIs at all in your code unless the border between your code and Apple’s always isolates the exception behavior

    • Every time your refactor, you’ll have to refactor a mass of exception handling code

    • Many things that should be trivial will be very complex; for example, you won’t be able to put your objects into an enumerable collection and enumerate them without that enumeration — block, for loop, whatever… — also having exception processing at the boundaries.

    Consider:

     NSArray *a = @[yourExceptionfulInstance, yourExceptionfulInstance, yourExceptionfulInstance];
    
    @try {
        for(id k in a) { [k doSomething]; }
    } @catch(...) {
    }
    

    If doSomething might raise, for any reason, the above is violation of the documented design patterns of the framework because you’ll be throwing an exception across frames within Apple’s framework(s).

    That is one mighty big con. Big enough that I can’t imagine a set of pros to outweigh it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read from some article that say's Apple doesn't approve the application which
I've read Apple is deprecating the UDID which a lot of people are relying
Having read Apple's numerous documentation on icon guidelines: http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/IconsImages/IconsImages.html#//apple_ref/doc/uid/TP40006556-CH14-SW2 http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/App-RelatedResources/App-RelatedResources.html#//apple_ref/doc/uid/TP40007072-CH6-SW1 http://developer.apple.com/library/ios/#qa/qa1686/_index.html I was wondering
I read through Apple's EADemo project. I then attempted my own. But when I
I have read the Apple documentation, and many postings on the subject on SO,
I was dumbfounded today, when I read that Apple has allowed PhoneGap apps for
I have read in the Apple Documentation that we can use optional parameters in
According to Apple documentation and other documentation I have read about on disk encryption
I'm trying to read EXIF data from pictures taken with the apple camera's application,
I need to read and serialize objects from and to XML, Apple's .plist format

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.