title: iphone pdf download
body: <pre><code>        -(IBAction)click;
      {
  
              NSURL *url = [NSURL URLWithString:URL_TO_DOWNLOAD]; 
              NSString *tempDownloadPath = [[self documentsDirectory] 
                                            stringByAppendingPathComponent:@"test.pdf"]; 
              ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; 
              [request setDownloadDestinationPath:[self documentsDirectory]]; 
              [request setTemporaryFileDownloadPath:tempDownloadPath]; 
              [request setDelegate:self]; 
  
    [request startAsynchronous]; 
  
  
          } 
  
      - (void)requestFinished:(ASIHTTPRequest *)request 
          { 
              NSLog(@"requestFinished"); 
              NSError *error; 
              NSFileManager *fileManager = [[NSFileManager alloc] init]; 
              NSLog(@"Documents directory: %@", [fileManager 
                                                 contentsOfDirectoryAtPath:[self 
                                                                            documentsDirectory] error:&amp;error]); 
              NSString *dir = [self documentsDirectory]; 
              NSLog(dir); 
              // NSData *responseData = [request responseData]; 
              NSArray *array = [[NSFileManager defaultManager] 
                                contentsOfDirectoryAtPath:dir error:&amp;error]; 
              if (array == nil) { 
                  NSLog(@"array == nil"); 
              } 
  else
  {
  [aWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:tempDownloadPath]]];
          [[self view] addSubview:aWebView];  
  }
  
              [fileManager release]; 
                  } 
  
      - (NSString *)documentsDirectory { 
              NSArray *paths = 
              NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 
                                                  NSUserDomainMask, 
                                                  YES); 
              return [paths objectAtIndex:0]; 
          } 
  </code></pre>
  
  <p>I cant manage to check if the file exists before downloading again with an click, or actually displaying the pdf one the request has finished. Any solutions to this ?</p>