1

My request is

        NSURL *requestUrl = [NSURL URLWithString:url];

    if(request_) {
        [request_ setDelegate:nil];
        [request_ release];
    }
    request_ = [[ASIFormDataRequest requestWithURL:requestUrl] retain];
    [request_ setDelegate:self];
    [request_ setRequestMethod:@"GET"];
    [request_ setTimeOutSeconds:HTTP_TIME_OUT];
    [request_ startAsynchronous];

The call is going since the network access indicator on the top bar is rotating and disappearing after a few seconds. But either of the delegate methods

- (void)requestFinished:(ASIHTTPRequest *)request

or

- (void)requestFailed:(ASIHTTPRequest *)request

is not being called. What could have went wrong?

Thanks in advance.

PS: Sometimes, due to some issue, server is returning a "500 Internal Server Error". But even in that case, shouldn't the delegate

- (void)requestFailed:(ASIHTTPRequest *)request

be called?

4

2 回答 2

4

你可以使用积木来检查。

这是相同的示例:

 NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"];
   __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
   [request setCompletionBlock:^{
      // Use when fetching text data
      NSString *responseString = [request responseString];

      // Use when fetching binary data
      NSData *responseData = [request responseData];
   }];
   [request setFailedBlock:^{
      NSError *error = [request error];
   }];
   [request startAsynchronous];

我希望这可能会有所帮助。

于 2012-06-01T06:57:02.157 回答
1

确保您的课程符合ASIHTTPRequestDelegate协议。

@interface YourClass : ... <ASIHTTPRequestDelegate>
于 2012-06-01T06:52:08.397 回答