Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.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
Xcode NSURLRequest中的HTTPMethod_Xcode_Swift_Nsurlrequest_Http Method - Fatal编程技术网

Xcode NSURLRequest中的HTTPMethod

Xcode NSURLRequest中的HTTPMethod,xcode,swift,nsurlrequest,http-method,Xcode,Swift,Nsurlrequest,Http Method,我试图将http方法设置为POST,但Xcode说它是一个get only属性 我是这样做的: request.HTTPMethod = "POST" var httpMethod:String? {get} 苹果的文档说我必须这样声明httpMethod: request.HTTPMethod = "POST" var httpMethod:String? {get} 但我不明白如何才能正常工作。NSURLRequest的默认行为是不可变的。如果希望能够编辑请求中的内容,则需要使用

我试图将http方法设置为POST,但Xcode说它是一个get only属性

我是这样做的:

 request.HTTPMethod = "POST"
var httpMethod:String? {get}
苹果的文档说我必须这样声明httpMethod:

 request.HTTPMethod = "POST"
var httpMethod:String? {get}

但我不明白如何才能正常工作。

NSURLRequest的默认行为是不可变的。如果希望能够编辑请求中的内容,则需要使用。然后可以像以前一样设置.HTTPMethod