Why doesn’t @try block work?
It crashed the app, but it was supposed to be caught by the @try block.
NSString* test = [NSString stringWithString:@"ss"];
@try {
[test characterAtIndex:6];
}
@catch (NSException * e) {
NSLog(@"Exception: %@", e);
}
@finally {
NSLog(@"finally");
}
Now I’ve found the problem.
Removing the
obj_exception_throwfrom my breakpoints solved this. Now it’s caught by the@tryblock and also,NSSetUncaughtExceptionHandlerwill handle this if a@tryblock is missing.