1
votes

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?

2
Use the NSLog to print some values. Also have you implemented the methods in the class? As you are assigning the delegate to self, there should be a definition of the methods in the same class.Akhilesh Sharma
I have implemented them. That is how I was able to know those were not being called.. :) :)DroidHeaven

2 Answers

4
votes

you can use the blocks to check that out.

here is the example of the same:

 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];

I hope this might help.

1
votes

Make sure your class is conforming to the ASIHTTPRequestDelegate protocol.

@interface YourClass : ... <ASIHTTPRequestDelegate>