NSException* ex = [[NSException alloc] initWithName:@"異常緣由" reason:@"程序奔潰" userInfo:nil];spa
@try {.net
bool error = YES;3d
if (error) {orm
@throw ex;get
}it
}io
@catch ( NSException *exception ) {class
NSLog(@"CustomNSException.name = %@" , exception.name);exception
NSLog(@"CustomNSException.reason = %@" , exception.reason);程序
// 彈出警告框,提示異常信息
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:exception.name message:exception.reason delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
[alert show];
}
@finally {
NSLog(@"@finally");
}