相关疑难解决方法(0)

@try - 在Objective-c中捕获块

为什么@try阻止工作?它崩溃了应用程序,但它应该被@try块捕获.

 NSString* test = [NSString stringWithString:@"ss"];

 @try {
    [test characterAtIndex:6];

 }
 @catch (NSException * e) {
    NSLog(@"Exception: %@", e);
 }
 @finally {
    NSLog(@"finally");
 }
Run Code Online (Sandbox Code Playgroud)

iphone objective-c try-catch-finally nsexception

189
推荐指数
2
解决办法
14万
查看次数

Try-Catch错误目标C.

我试图从给定的Instagram图片中获取字幕,但是如果没有标题,应用程序会抛出异常并崩溃.我将如何实现@try@catch执行此操作.这是我到目前为止:

@try {
    RNBlurModalView *modal = [[RNBlurModalView alloc] initWithViewController:self title:[NSString stringWithFormat:@"%@",entry[@"user"][@"full_name"]] message:[NSString stringWithFormat:@"%@",text[@"caption"][@"text"]]];
    [modal show];
}
@catch (NSException *exception) {
    NSLog(@"Exception:%@",exception);
}
@finally {
  //Display Alternative
}
Run Code Online (Sandbox Code Playgroud)

error-handling objective-c try-catch-finally ios

3
推荐指数
1
解决办法
2万
查看次数