Question

I have

-(void)requestFailed:(ASIHTTPRequest *)request
{
    NSError *error = [request error];
    NSLog(@"Request Failed Error: %@", error);
}

When I make my request I do

    //add data to the array
    NSString *json = [array JSONRepresentation];
[request appendPostData:[json dataUsingEncoding:NSUTF8StringEncoding]];

[request startAsynchronous];

I'm getting this in my log:

 0-08-11 16:52:11.652 MyProject[11720:207] Starting asynchronous request <ASIHTTPRequest: 0x5a7df10>

2010-08-11 16:52:11.861 MyProject[11720:207] Request finished downloading data 2010-08-11 16:52:11.861 MyProject[11720:207] Request failed: (gdb)

But my log statement in

 -(void)requestFailed

is not getting called. Any ideas?

Cheers

Was it helpful?

Solution

-requestFailed: is only returned when a request can't be completed - eg. failure to contact the server, or the server didn't conform to the http protocol.

If request can be completed, requestFinished will be called, and you can then check the http status code there, which may indicate a failure. responseStatusText may give more information as to what the failure was.

OTHER TIPS

Did you set the request's delegate and didFailSelector properties? Usually:

[request setDelegate:self];
[request setDidFailSelector:@selector(requestFailed:)];

suffices if the -requestFailed: method is in the same class implementation file.

Also set the didFinishSelector property to call a local selector when then request finishes correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top