Re: Objective-C Question
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.