POST方法要设置HTTPmethod HTTPbody
同步请求代码核心代码:43 NSData *data=[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
异步请求 NSOperationQueue *queue=[NSOperationQueue mainQueue];
53 [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
如果用到代理 核心代码
NSURLRequest *request=[NSURLRequest requestWithURL:url];//默认就是GET请求
//设置请求超时
NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url];
request.timeoutInterval=5.0;
// 2.3.发送请求
//使用代理发送异步请求(通常应用于文件下载)
NSURLConnection *conn=[NSURLConnection connectionWithRequest:request delegate:self];
[conn start];
NSLog(@"已经发出请求---");
}
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);