Alamofire发送具有多种数据的阵列

时间:2016-04-19 09:19:28

标签: ios alamofire

代码:

 var arrType = ["first", "second","thrird"]


   upload(
            .POST,
            urlString,
            multipartFormData: { multipartFormData in

            multipartFormData.appendBodyPart(data: strDescription.dataUsingEncoding(NSUTF8StringEncoding)!, name:"business_description")    
                for (var i = 0; i < arrType.count; i++){

                      multipartFormData.appendBodyPart(data: arrType[i].dataUsingEncoding(NSUTF8StringEncoding)!, name:"vehicle_types[]")
                } 
            },
            encodingCompletion: { encodingResult in
                switch encodingResult {
                case .Success(let upload, _, _):
                    upload.responseJSON { response in

                        print("A JSON Result :\(response.result.value)")
                        if let JSON = response.result.value
                        {
                            print("A JSON Result :\(JSON)")
                        }
                        else
                        {
                            print("A JSON parsing error occurred, here are the details: %@" ,response.result.error)
                            delegate.API_CALLBACK_Error(0,errorMessage:c_Server_error)
                        }
                    }
                case .Failure( _):
                    break
                }
        })

我尝试通过多种数据发送数组。 当尝试执行此代码从服务器获取失败响应时 是否正确发送具有多种数据的数组? 任何帮助都会被提前感谢。谢谢你们。

0 个答案:

没有答案