views:

403

answers:

2

I want to check the last modified date on a file on a web server. Any help would be great. Thanks.

A: 

You can have the CMS write a file containing a date of modification. You can then download that file using a number of [:initWithURL] methods. Compare that date to the whatever stored date that you have.

I suppose you can also ftp the desired file. Then use NSFileManager to look at properties of the file, NSString *NSFileModificationDate will give you a date that you can compare with whatever stored date you want.

You can search SO for ftp solutions.

Jordan
+2  A: 
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:aURL];
NSHTTPURLResponse *response;
[NSURLConnection sendSynchronousRequest:request                 returningResponse:&response error:nil];
if( [response respondsToSelector:@selector( allHeaderFields )] )
{
    NSDictionary *metaData = [response allHeaderFields];
    NSString *lastModifiedString = [metaData objectForKey:@"Last-Modified"];
}
Brian