开发者

ASIHTTP Request failed in log, but requestFailed not getting called

I have

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

When I make my requ开发者_运维百科est 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


-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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜