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 に答える