-
Notifications
You must be signed in to change notification settings - Fork 765
NSURLConnection
戴铭 edited this page Mar 11, 2015
·
1 revision
- NSURLRequest
- NSURLResponse
- NSURLProtocol
- NSURLCache
- NSHTTPCookieStorage
- NSURLCredentialStorage
- NSURLConnection
NSURLRequest被传递给NSURLConnection。NSURLConnectionDelegate和NSURLConnectionDataDelegate异步返回一个NSURLResponse以及包含服务器返回信息的NSData
请求到达服务器前会查询缓存信息,根据policy和availability不同,一个被缓存的响应会被立即返回。
简化代码一次性使用request
NSURL *URL = [NSURL URLWithString:@"http://example.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
// ...
}];