• 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: Objective-C Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C Question


  • Subject: Re: Objective-C Question
  • From: Jim Correia <email@hidden>
  • Date: Mon, 22 Sep 2003 18:45:22 -0400

On Monday, September 22, 2003, at 06:23 PM, Chris Hanson wrote:

On Monday, September 22, 2003, at 05:09 AM, Marcel Weiher wrote:
Precisely. Anyway, gcc 3.3 now has exceptions "built-in", apparently to appease those who think that this "must" be a language feature. Functionally, I have a hard time detecting any difference. Maybe if I squint right...

The @finally clause is convenient. Instead of

NS_DURING {
// something that could raise

// do any necessary clean-up
}
NS_HANDLER {
// handle the exception

// do any necessary clean-up (repeated from the NS_DURING block)
}
NS_ENDHANDLER

While I agree that @finally is welcome, you don't always need to duplicate your cleanup like above. Something like this can avoid it:

NSException *caught_exception = nil;

NS_DURING
{
// something that could raise
}
NS_HANDLER
{
caught_exception = localException;
}
NS_ENDHANDLER

if (caught_exception)
{
// handle exception as necessary
}

// cleanup code

if (caught_exception)
{
// re-raise exception as necessary
}

Jim
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Objective-C Question (From: Chris Hanson <email@hidden>)

  • Prev by Date: Re: Objective-C Question
  • Next by Date: Re: Objective-C Question
  • Previous by thread: Re: Objective-C Question
  • Next by thread: Re: Objective-C Question
  • Index(es):
    • Date
    • Thread