为什么@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) 我试图从给定的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)