1

我试图在我的代码中捕捉除以 0 算术异常,但看起来 NSException 没有捕捉到它并且程序以消息exc_arthimetic错误终止。捕获异常的方法是什么

     @try {

         int k;

         printf("please enter k value \n");
         scanf("%i",&k);

         int j=1;

         // testing division 1/0 condition
         int i=j/k;
         NSLog(@" value of i= %i",i);
     }

     @catch (NSException *exception) {
         NSLog(@"exception is = %@  reason is %@",[exception name],[exception reason]);
     }
     @finally {
         NSLog(@"inside finally");
     }


     NSLog(@" last line");
4

1 回答 1

2
于 2012-05-22T19:13:57.057 回答