我想编写一些代码来处理HTTP连接失败时的异常.我使用以下代码:
-(void) connection:(NSURLConnection *)connection didFailWithError: (NSError *)error { UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle: [error localizedDescription] message: [error localizedFailureReason] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [errorAlert show]; [errorAlert release]; [activityIndicator stopAnimating]; NSLog (@"Connection Failed with Error"); }
但是当连接失败时程序崩溃了.如何在没有程序崩溃的情况下弹出警报?