iOS 用@try @catch捕获异常

2015-11-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;

}

上一篇 下一篇

猜你喜欢

热点阅读