Search code examples
swiftalamofire

Append parameters in Alamofire Swift


I have the follow array

let p = [
        "id": id
    ]

I would like to append these if they are added.

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

However, I do not see anything for this array type to append, or add, etc.


Solution

  • Alamofire parameter is a Dictionary not an array.So you need to add new items like this

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

    more info : https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#making-requests