美文网首页
iOS 用@try @catch捕获异常

iOS 用@try @catch捕获异常

作者: 细雨听风 | 来源:发表于2015-11-03 16:03 被阅读94次

NSString *name = @"哈哈哈哈";

name = nil;

@try

{

NSDictionary *dict = @{@"name":name};

}@catch (NSException * e) {

NSLog(@"Exception: %@", e);

UIAlertView * alert =

[[UIAlertView alloc]

initWithTitle:@"错误"

message: [[NSString alloc] initWithFormat:@"%@",e]

delegate:self

cancelButtonTitle:nil

otherButtonTitles:@"OK", nil];

[alert show];

[alert release];

return;

}

相关文章

网友评论

      本文标题:iOS 用@try @catch捕获异常

      本文链接:https://www.haomeiwen.com/subject/msvqhttx.html