• 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: Recuperating after NS_HANDLER
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recuperating after NS_HANDLER


  • Subject: Re: Recuperating after NS_HANDLER
  • From: Marcel Weiher <email@hidden>
  • Date: Sun, 16 May 2004 10:06:52 +0100

On 16 May 2004, at 08:59, Francisco Tolmasky wrote:

I would like to do something like the following:

while(someStuff)
{
NS_DURING
something that could throw an exception
NS_HANDLER
handle it
NS_ENDHANDLER
}

I would like it to continue the loop even if it does reach an exception, is this possible? This code above does not seem to be working.

It should work:

marcel@tuvuk[Backup]cd /tmp/
marcel@tuvuk[tmp]cat >exceptionTest.m
#import <Foundation/Foundation.h>

int main( int argc, char *argv[] )
{
int loops=20;
while ( loops-- > 0 ) {
id nsarray=[[NSMutableArray alloc] init];
NS_DURING
[nsarray addObject:nil];
NS_HANDLER
NS_ENDHANDLER
printf("%d loops remain\n",loops);
[nsarray release];
}
return 0;
}
marcel@tuvuk[tmp]cc -Wall -O -o exceptionTest exceptionTest.m -framework Foundation
marcel@tuvuk[tmp]./exceptionTest 2>/dev/null
19 loops remain
18 loops remain
17 loops remain
16 loops remain
15 loops remain
14 loops remain
13 loops remain
12 loops remain
11 loops remain
10 loops remain
9 loops remain
8 loops remain
7 loops remain
6 loops remain
5 loops remain
4 loops remain
3 loops remain
2 loops remain
1 loops remain
0 loops remain
marcel@tuvuk[tmp]
_______________________________________________
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: 
 >Recuperating after NS_HANDLER (From: Francisco Tolmasky <email@hidden>)

  • Prev by Date: Re: Recuperating after NS_HANDLER
  • Next by Date: Re: Detect ALT key pressed during dragging
  • Previous by thread: Re: Recuperating after NS_HANDLER
  • Next by thread: Re: Recuperating after NS_HANDLER
  • Index(es):
    • Date
    • Thread