1

说,我可以得到http://www.google.com的服务器时间吗?

如何在 ObjC 中做到这一点?

4

1 回答 1

2

当然:

NSURLRequest *rq = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]];
[NSURLConnection sendAsynchronousRequest:rq queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *resp, NSData *data, NSError *err) {
    NSDictionary *headers = [(NSHTTPURLResponse *)resp allHeaderFields];
    NSString *dateString = [headers objectForKey:@"Date"];
    NSLog(@"Google Server Date: %@", dateString);
}];
于 2013-02-21T17:31:56.560 回答