在 Alamofire Swift 中附加参数

sol*_*for 1 swift alamofire

我有以下数组

let p = [
        "id": id
    ]
Run Code Online (Sandbox Code Playgroud)

如果添加的话我想附加它们。

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

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

Dil*_*lan 6

Alamofire 参数是字典而不是数组。所以你需要像这样添加新项目

if (minPriceUsed) {
      p["minPrice"] = minPriceText!
}
if (maxPriceUsed) {
      p["maxPrice"]. = maxPriceText!
}
Run Code Online (Sandbox Code Playgroud)

更多信息:https ://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#making-requests