i want to use - (void)requestFailed:(ASIHTTPRequest *)request, to alert user that there is an error with the network ( it can not connect to the networ开发者_如何学Ck) how i can recuper the error and implement this method,
thanks
To implement this method, your classe should be the delegate of your request :
[request setDelegate:self];
Then the method will automatically be called if the request failed
- (void)requestFailed:(ASIHTTPRequest *)request
{
NSLog(@"Error %@", [request error]);
if ([request error]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Fail."
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
return;
}
}
You can set the delegate of ASIHTTPRequest by
request.delegate = self;
which will enable you to use this method.
you can simply print the alert if error occurs using uialertView thanks
精彩评论