@try - 在Objective-c中捕获块 [英] @try - catch block in Objective-c
本文介绍了@try - 在Objective-c中捕获块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么@try阻止不起作用?
它崩溃了应用程序,但它应该被@try块捕获。
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");
}
推荐答案
现在我找到了问题。
从我的断点中删除 obj_exception_throw
解决了这个问题。现在它被 @try
块捕获,而 NSSetUncaughtExceptionHandler
将处理这个,如果 @尝试
块丢失。
Removing the obj_exception_throw
from my breakpoints solved this. Now it's caught by the @try
block and also, NSSetUncaughtExceptionHandler
will handle this if a @try
block is missing.
这篇关于@try - 在Objective-c中捕获块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文