Objective c 比较两个国家统计局的数据

Objective c 比较两个国家统计局的数据,objective-c,nsdata,Objective C,Nsdata,在我的项目中,我需要比较一个网站是否从现在更改到30分钟后,因此经过研究,我得出以下结论: - (IBAction)saveHTML:(id)sender{ // Determile cache file path NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *filePath = [NSString s

在我的项目中,我需要比较一个网站是否从现在更改到30分钟后,因此经过研究,我得出以下结论:

- (IBAction)saveHTML:(id)sender{
    // Determile cache file path
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *filePath = [NSString stringWithFormat:@"%@/%@", [paths objectAtIndex:0],@"index.html"];

    self.Surl= [self.meuWebView stringByEvaluatingJavaScriptFromString:@"window.location.href"];
    NSLog(@"URL: %@",self.Surl);
    // Download and write to file
    NSURL *url = [NSURL URLWithString:self.Surl];
    NSData *urlData = [NSData dataWithContentsOfURL:url];
    [urlData writeToFile:filePath atomically:YES];

    // Load file in UIWebView
    //   [web loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:filePath]]];

    self.oldURL = urlData;
    self.timerURLNew = [NSTimer scheduledTimerWithTimeInterval:5 target:self     selector:@selector(saveHTMLNew:) userInfo:[NSNumber numberWithBool:YES] repeats:NO];
}

-(void)saveHTMLNew:(id)sender{
    // Determile cache file path
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *filePath = [NSString stringWithFormat:@"%@/%@", [paths objectAtIndex:0],@"index.html"];

    self.Surl= [self.meuWebView stringByEvaluatingJavaScriptFromString:@"window.location.href"];
    NSLog(@"%@",self.Surl);

    NSURL *url = [NSURL URLWithString:self.Surl];
    NSData *urlData = [NSData dataWithContentsOfURL:url];
    [urlData writeToFile:filePath atomically:YES];
    self.newURL = urlData;

    if (![self.oldURL isEqualToData:self.newURL]) {
        NSLog(@"Something changed");
    }
    else {
        NSLog(@"Nothing changed");
    }
}

问题是每次我都会改变一些东西。为了进行测试,我创建了一个博客来发布一些东西来更改其HTML。

如果您的服务器支持HTTP Last Modified值,为什么不使用它呢?使用一个比较方案,向您展示发生了什么变化,您将更接近于找到解决方案。