Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在iOS中进行连接呼叫?_Ios_Http_Nsurlsession - Fatal编程技术网

如何在iOS中进行连接呼叫?

如何在iOS中进行连接呼叫?,ios,http,nsurlsession,Ios,Http,Nsurlsession,NSURLSession支持POST和GET;它也支持连接吗 如果是,确切的语法是什么 谢谢 使用NSMutableURLRequest设置所需的任何HTTP方法 let session = NSURLSession() guard let url = NSURL(string: "http://www.google.com") else { fatalError("Error creating NSURL for http://www.google.com") } let requ

NSURLSession支持POST和GET;它也支持连接吗

如果是,确切的语法是什么


谢谢

使用
NSMutableURLRequest
设置所需的任何HTTP方法

let session = NSURLSession()

guard let url = NSURL(string: "http://www.google.com") else {
    fatalError("Error creating NSURL for http://www.google.com")
}

let request = NSMutableURLRequest(URL: url)
request.HTTPMethod = "CONNECT"

let task = session.dataTaskWithRequest(request)

task.resume()

谢谢你的回答!