I use code as below to compare file's last modified date between iPad and Internet, but the date is GMT format on Web, and date format is local on iPad, how can I compare them?
Code:
NSString *url = [NSString stringWithFormat:@"http://protra.sourceforge.jp/data/index.txt.lzh"];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
NSHTTPURLResponse *response = nil;
NSError *error = nil;
[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if ([response respondsToSelector:@selector(allHeaderFields)]) {
NSDictionary *metaData = [response allHeaderFields];
NSString *lastModifiedString = [metaData objectForKey:@"Last-Modified"];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *indexFile = [self pathInDocumentsFolder:kIndexFile];
NSDate *lastDate = [[fileManager attributesOfItemAtPath:indexFile error:nil] fileModificationDate];
NSString *lastDateString = [lastDate description];
if ([lastDateString compare:lastModifiedString]) {
return YES;
}
else {
return NO;
}
}