在Alamofire Swift中发送数组作为参数
问题描述:
我试图将数组作为参数,但结果永远不会成功。在Alamofire Swift中发送数组作为参数
这里是我的参数:
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
从来没有成功。我也尝试添加[String: Any]
,但仍然无法正常工作。
答
我解决它使用:
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")
上面的例子所创建的字典,而不是阵列。你能展示你期望创造什么吗? –
我将值追加到数组并将它们作为参数发送 –
您能否用相关代码来解释一些问题 –