• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: try/catch/throw/finally example?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: try/catch/throw/finally example?


  • Subject: Re: try/catch/throw/finally example?
  • From: Chris Hanson <email@hidden>
  • Date: Fri, 25 Aug 2006 19:39:28 -0700

On Aug 25, 2006, at 4:10 PM, Keith Ray wrote:

I noticed that even though the compiler doesn't complain about about a
missing catch block, if it *is* missing, the finally block is never
executed.


@try { [stringOne appendString:stringTwo]; } @finally { NSLog(@"This always happens."); }

The compiler can't know if any particular message expression is going to result in a thrown exception, because Objective-C neither has nor requires exception specifications.


The compiler also can't know if an exception thrown out of the @try block won't be caught by the caller of the method that contains the above code, because the compiler can't deterministically know the caller of any method.

On the other hand, the @finally block should always be executed. If you encounter situations in which you write code like the above and the @finally block isn't executed, you should definitely file a bug with as close to a reproducible case as you can.

  -- Chris

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >try/catch/throw/finally example? (From: Roland Silver <email@hidden>)
 >Re: try/catch/throw/finally example? (From: Todd Yandell <email@hidden>)
 >Re: Re: try/catch/throw/finally example? (From: "Keith Ray" <email@hidden>)

  • Prev by Date: Re: Newbie question of the day.
  • Next by Date: NSTableView using Square Button for image
  • Previous by thread: Re: Re: Re: try/catch/throw/finally example?
  • Next by thread: Re: try/catch/throw/finally example?
  • Index(es):
    • Date
    • Thread