Objective-c is not a catch exception in a try / catch block

I have this statement inside a try / catch block, but the exception never gets caught. In fact, any thrown exception never gets caught. Can anybody help me?

Is there any parameter disabled in the xcode project that disables catching exceptions?

NSString *test = @"test";
unichar a;
int index = 5;

@try {
    a = [test characterAtIndex:index];
}
@catch (NSException *exception) {
    NSLog(@"%@", exception.reason);
}
@finally {
    NSLog(@"Char at index %d cannot be found", index);
    NSLog(@"Max index is: %lu", [test length]-1);
}

* - "NSRangeException", : '- [__ NSCFConstantString characterAtIndex:]: " * : (0x1832ad900 0x18291bf80 0x1832ad848 0x1831a52f0 0x100249340 0x188015704 0x188244130 0x1882484b8 0x1882455c0 0x184863790 0x184863b10 0x183264efc 0x183264990 0x183262690 0x183191680 0x18800e580 0x188008d90 0x10017662c 0x182d328b8) lib++ abi.dylib: NSException

+4
3

- -Wl,-no_compact_unwind .

, .

Pic

+1

build settingsEnable Objective-C Exceptions

.

enter image description here

0

Use a physical device instead of a simulator.

Notes here - https://gist.github.com/johndpope/89c00eccbdd6e87720724dabd82b8774

0
source

All Articles