title: HEADER request allHeaderFields not working
body: <p>The purpose of my code is to compare the modification dates of a server file and a local file, in case that the server file is newer, it will download it.</p>
  
  <p>My first attempt was to use a synchronous request using the code from <a href="http://iphoneincubator.com/blog/server-communication/how-to-download-a-file-only-if-it-has-been-updated" rel="nofollow">http://iphoneincubator.com/blog/server-communication/how-to-download-a-file-only-if-it-has-been-updated</a></p>
  
  <p>But it didn't worked.
  After that I've been struggling to find the solution, tried asynchronous request, tried different codes I found around stackoverflow, google, etc. but nothing works.</p>
  
  <p>If in terminal I do <code>curl -I &lt;url-to-file&gt;</code> I get the header values so I know is not a server problem.</p>
  
  <p>This is the code I'm struggling with right now (It's written in Appdelegate.m)</p>
  
  <pre><code>- (void)downloadFileIfUpdated {
  NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: url
                                                         cachePolicy: NSURLRequestReloadIgnoringLocalCacheData
                                                     timeoutInterval: 10];
  [request setHTTPMethod:@"HEAD"];
  
  NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
    if(!connection) {
      NSLog(@"connection failed");
    } else {
      NSLog(@"connection succeeded");
    }
  }
  
  
  
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
      [self downloadFileIfUpdated]
  }
  
  
  
  #pragma mark NSURLConnection delegate methods
  - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
  NSString *lastModifiedString = nil;
  NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response;
    if ([response respondsToSelector:@selector(allHeaderFields)]) {
      lastModifiedString = [[response allHeaderFields] objectForKey:@"Last-Modified"];
    }
    [Here is where the formatting-date-code and downloading would take place]
  }
  </code></pre>
  
  <p>Right now, as it is, it gives me the error <code>No visible @interface for 'NSURLResponse' declares de selector 'allHeaderFields'</code>.</p>
  
  <p>When I use the synchronous approach the error is that <code>NSLog(@"%@",lastModifiedString)</code>returns (null).</p>
  
  <p>PS: If there is a better way I can explain myself or the code, please let me know.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The URL I'm using is of type <code>ftp://</code>and that may be the problem of why I don't get any HEADERS. But I can't figure out how to do it then.</p>