I want to write some code to handle exceptions when HTTP connection fails. I use the following codes:
-(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");
}
But the programme just crashes when the connection fails. How to let the alert pop up without program crash?