gpt4 book ai didi

ios - Swift Alamofire multipartFormData.appendBodyPart Bool?

转载 作者:搜寻专家 更新时间:2023-11-01 07:28:45 25 4
gpt4 key购买 nike

我目前在上传带有参数和标题的图像时卡在我的学校项目中。问题是我不知道如何将 Bools 添加到 multipartFormData。有人知道吗?

multipartFormData.appendBodyPart(
data: self.house.image!,
name: "file",
fileName: "testIMG.png",
mimeType: "image/png"
)
multipartFormData.appendBodyPart(data:self.house.streetName!.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!, name :"streetName")
multipartFormData.appendBodyPart(data:self.house.streetNumber!.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!, name :"streetNumber")
multipartFormData.appendBodyPart(data:self.house.city!.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!, name :"city")
multipartFormData.appendBodyPart(data:self.house.zipcode!.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!, name :"zipcode")
multipartFormData.appendBodyPart(data:self.house.kitchen_shared!.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!, name :"kitchen_shared")
multipartFormData.appendBodyPart(data:self.house.livingroom_shared!.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!, name :"livingroom_shared")
multipartFormData.appendBodyPart(data:self.house.bathroom_shared!, name :"bathroom_shared")
},

kitchen_shared、livingroom_shared 和 bathroom_shared 是我坚持使用的 Bool。

最佳答案

将值作为字符串发送,因为任何参数都是 http 请求正文中的字符串。捕获变量 @backend 并将其解析为 bool 值(这取决于您的后端实现)。

multipartFormData.appendBodyPart(data:self.house.livingroom_shared.description.dataUsingEncoding(NSUTF8StringEncoding)!,name:"kitchen_shared")

关于ios - Swift Alamofire multipartFormData.appendBodyPart Bool?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34041166/

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