我要發佈數據作爲參數是這樣的:Alamofire:發送參數
{
"data":
[
{
"nik" : "lalaal"
}
]
}
我怎樣寫在斯威夫特3這些參數使用Alamofire
?
我想:
let parameter: Parameters = [
"data":[[
"nik" : self.nik,
"check_type" : "IN",
"tanggal" : "01-08-2017 18:22:00",
"long" : String(locationList[projectChoosen].long!),
"lat" : String(locationList[projectChoosen].lat!),
"id_loc" : locationList[projectChoosen].id_project,
"id_project" : nil,
"nama_project" : locationList[projectChoosen].nama_project,
"barcode" : "",
"foto": "",
"mime_type" : "image/jpeg"
]]
]
顯示你試過代碼 –
試試這個:Alamofire.request( 「URL」,方法:.POST,參數:參數,編碼:JSONEncoding.default) – KKRocks
https://stackoverflow.com/a/45437228/ 1242673 –