1
#import <Foundation/Foundation.h>
main() {
NSURL *url = [NSURL URLWithString:@"http://www.google.com/"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:60];
NSURLResponse *response;
NSError *error;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSLog(@"Data were download below:\n%@", [[NSString alloc] initWithData:data encoding: NSASCIIStringEncoding]);
}
运行可执行文件 - > 数据均低于下载: [空]简单的HTTP请求C未工作
为什么?
明显的问题:“错误”是什么意思? – zoul
if(error!= nil)[error userInfo] - >分段错误 – sof
现在这很有趣。即使普通的'NSLog(@“%@”,错误)'这样做? – zoul