我想从一个给定的Instagram图片标题,但如果没有字幕的应用程序将引发异常和崩溃。我将如何执行@try
和@catch
来执行此操作。以下是我迄今为止:的try-catch错误目标C
@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
}
你有没有在你的NSLog声明试图[异常原因],而不是仅仅例外。 – asafreedman
我真的不知道如何能告诉我如何? – Prad
我认为你也抛出异常? Objective-C中不鼓励使用这种常见情况的例外情况。例外情况是......以及程序无法恢复的特殊情况。相反,为什么不使用'NSError'对象,并在没有标题的情况下通知用户。 – borrrden