在Alamofire Swift 3中将数组作为参数发送

时间:2017-04-01 07:52:07

标签: swift alamofire

我试图将数组作为参数,但结果永远不会成功。

这是我的参数:

RewriteRule ^ http://shop.abc.com%{REQUEST_URI} [R=301,QSA,L]

如果打印参数:

let params: [String: Any] = [

        "debug": "1",
        "check_in": checkIn,
        "check_out": checkOut,
        "theme": theme,
        "beds": Beds,
        "bedrooms": Bedroom,
        "bathrooms": Bathroom,
        "facility": idFacility,
        "room_type": id,
        "page": 1,
        "take": 10,
        "id_user": sessionId
    ]

    print(params)
    print("THE PARAMS")

我不明白,如果我发送单个字符串或整数,它可以工作。但是如果是数组,[ "take": 10, "page": 1, "debug": "1", "id_user": 103, "theme": [17, 18, 19], "check_in": "2017-04-01", "check_out": "2017-04-02", "bedrooms": 1, "beds": 1, "room_type": [5, 6, 7], "facility": [11, 12, 13], "bathrooms": 1] 永远不会成功。我还尝试添加response.result.value但仍然无法正常工作。

1 个答案:

答案 0 :(得分:1)

我使用:

解决了它
let params: [String: Any] = [

        "debug": "1",
        "city": city,
        "check_in": checkIn,
        "check_out": checkOut,
        "max_guest": maxGuest,
        "theme": String(describing: theme),
        "currency": "IDR",
        "price_min": priceMinimum,
        "price_max": priceMaximum,
        "beds": Beds,
        "bedrooms": Bedroom,
        "bathrooms": Bathroom,
        "facility": String(describing: idFacility),
        "room_type": String(describing: id),
        "page": 1,
        "take": 10,
        "id_user": sessionId
    ]

    print(params)
    print("THE PARAMS")