Swift :
1: NSURLConnectionDataDelegate.
class ViewController: UIViewController,NSURLConnectionDataDelegate {
2. .
var request:NSMutableURLRequest = NSMutableURLRequest(URL: NSURL(string: "http://www.twitter.com")!)
request.HTTPMethod = "HEAD"
3: .
var connection:NSURLConnection = NSURLConnection(request: request, delegate: self)!
4. NSURLConnectionDataDelegate
func connection(connection: NSURLConnection, didReceiveResponse response: NSURLResponse)
{
var size = response.expectedContentLength
println("size : \(size)")
}
...
import UIKit
class ViewController: UIViewController,NSURLConnectionDataDelegate {
override func viewDidLoad() {
super.viewDidLoad()
var request:NSMutableURLRequest = NSMutableURLRequest(URL: NSURL(string: "http://www.twitter.com")!)
request.HTTPMethod = "HEAD"
var connection:NSURLConnection = NSURLConnection(request: request, delegate: self)!
}
func connection(connection: NSURLConnection, didReceiveResponse response: NSURLResponse)
{
var size = response.expectedContentLength
println("size : \(size)")
}
}