Exception Handling in Obj-C

I read about exception handling in Apple Developer Docs , but I was wondering why the exceptions to standard C operations are not caught?

eg. The code below still crashes the application without intercepting the div to zero. Will the try / @ catch block only remove Obj-C code?

@try { int i = 10 / 0; } @catch (NSException * e) { NSLog(@"Div by zero!"); } @finally { // Nothing... } 
+6
c objective-c exception exception-handling
source share
1 answer

Division by zero is not an exception of type NSException . In fact, this is also not an “exception” from the point of view of the programming language. C itself does not have any exceptions, similar to how C ++, Java, etc. do it. When dividing by 0 in C, a “processor” is thrown, and an error is thrown at a much lower level.

+3
source share

All Articles