开发者

Objective C - Caught exception causes crash

I'm doing some Objective C tests. I'm raising a custom exception with this code:

- (double)foo:(int)x{
   if (x == 0){
      [NSException raise:@"InvalidX" format:@"X can't be 0"];
   }
   return 1/x;
}

and catching it with this code:

@try {
   double y = [self foo:0];
} @catch (NSException *e) {
   return;
}
开发者_JAVA百科

It works good if i run the application in XCode but it crashes when i run the .app:

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000

Application Specific Information:
objc[1769]: garbage collection is OFF
*** Terminating app due to uncaught exception 'InvalidX', reason: 'X can't be 0'
*** First throw call stack:

It doesn't look "uncaught"! I can't explain this

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜