gpt4 book ai didi

swift - 阿拉莫菲尔中的 `Extra argument method in call`

转载 作者:行者123 更新时间:2023-11-30 11:27:06 30 4
gpt4 key购买 nike

我尝试使用 Alamofire 版本 3 和 Swift 3 发送以下数据。我得到的错误是调用中的额外参数方法。这是我到目前为止所做的:

struct userGoalServerConnection {
let WeightsUserGoal_POST = "http://api.umchtech.com:3000/AddWeightsGoal"


}


struct wieghtsUserGoal {
let id : Int
let token : String
let data : [ String : String ]
}


func syncInitialUserGaolValuesWithServer (userID : Int , userToken : String ){
let serverConnection = userGoalServerConnection()
let weightValue = wieghtsUserGoal.init(id: userID,
token: userToken,
data: ["weight_initial":"11","weight_end":"11","weight_difference":"11","calories_deficit":"11","difficulties":"11","weight_loss_week":"11","start_date":"2016-12-12","end_date":"2016-12-23","days_needed":"11"])

Alamofire.request(userGoalServerConnection.WeightsUserGoal_POST, method:.post, parameters: weightValue, encoding: JSONEncoding.default, headers:nil).responseJSON { response in
print(response.request as Any) // original URL request
print(response.response as Any) // URL response
print(response.result.value as Any) // result of response serialization
}

我对此很陌生,所以请不要介意我的问题是否有点太菜鸟了。我在这里遇到了类似的问题,但它们并没有帮助我弄清楚我在哪里犯了错误:)

最佳答案

您正在请求中将 weightValue 作为 POST 参数传递,但事实并非如此。如果您使用 JSONEncoding,则传递 Parameters 对象的类型。

let params: Parameters = [
"Key1": "value1",
"key2": "value2"
]

关于swift - 阿拉莫菲尔中的 `Extra argument method in call`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50621366/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com