Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.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
在Alamofire Swift中附加参数_Swift_Alamofire - Fatal编程技术网

在Alamofire Swift中附加参数

在Alamofire Swift中附加参数,swift,alamofire,Swift,Alamofire,我有下面的数组 let p = [ "id": id ] 我想附加这些,如果他们被添加 if (minPriceUsed) { //p.add(["minPrice": minPriceText!]) } if (maxPriceUsed) { //p.add(["maxPrice": maxPriceText!]) } 但是,我没有看到此数组类型需要附加或添加的任何内容。您需要的是字典而不是数组 var

我有下面的数组

let p = [
        "id": id
    ]
我想附加这些,如果他们被添加

    if (minPriceUsed) {
        //p.add(["minPrice": minPriceText!])
    }
    if (maxPriceUsed) {
        //p.add(["maxPrice": maxPriceText!])
    }

但是,我没有看到此数组类型需要附加或添加的任何内容。

您需要的是字典而不是数组

var p = [
    "id": id
]   


你需要的不是数组,而是字典

var p = [
    "id": id
]   


Alamofire参数是一个字典而不是一个数组

if (minPriceUsed) {
      p["minPrice"] = minPriceText!
}
if (maxPriceUsed) {
      p["maxPrice"]. = maxPriceText!
}

更多信息:

Alamofire参数是一个字典,而不是数组。因此,您需要添加如下新项

if (minPriceUsed) {
      p["minPrice"] = minPriceText!
}
if (maxPriceUsed) {
      p["maxPrice"]. = maxPriceText!
}
更多信息: