ios – objective-c没有在trycatch块中捕获异常

ios – objective-c没有在trycatch块中捕获异常,第1张

概述我在try / catch块中有这个语句,但是异常永远不会被捕获.实际上,抛出的任何异常都不会被捕获. 谁能帮我? 是否在xcode项目中禁用了禁用捕获异常的设置? NSString *test = @"test";unichar a;int index = 5;@try { a = [test characterAtIndex:index];}@catch (NSExcept 我在try / catch块中有这个语句,但是异常永远不会被捕获.实际上,抛出的任何异常都不会被捕获.
谁能帮我?

是否在xcode项目中禁用了禁用捕获异常的设置?

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);}

* Terminating app due to uncaught exception ‘NSRangeException’,reason: ‘-[__NSCFConstantString characteratIndex:]: Range or index out
of bounds’
* First throw call stack: (0x1832ad900 0x18291bf80 0x1832ad848 0x1831a52f0 0x100249340 0x188015704 0x188244130 0x1882484b8
0x1882455c0 0x184863790 0x184863b10 0x183264efc 0x183264990
0x183262690 0x183191680 0x18800e580 0x188008d90 0x10017662c
0x182d328b8) libc++abi.dylib: terminating with uncaught exception of
type NSException

解决方法 就我而言,还有一个其他liker Flag -Wl,-no_compact_unwind in
我的项目的构建设置.

我删除它,然后问题得到解决.

总结

以上是内存溢出为你收集整理的ios – objective-c没有在try / catch块中捕获异常全部内容,希望文章能够帮你解决ios – objective-c没有在try / catch块中捕获异常所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1029510.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-23
下一篇2022-05-23

发表评论

登录后才能评论

评论列表(0条)

    保存