I am trying to append some parameters to my Alamofire request.
var parameters = [String: AnyObject]()
parameters["firstimg"] = fetchedImagesArray[0] as AnyObject?
parameters["secondimg"] = fetchedImagesArray[1] as AnyObject?
Then:
for (key, value) in parameters {
multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: key)
}
But when I try to append the parameters I get the error: Cannot call value of non-function type UInt -> Data
You need to cast value
as String
to use the data(using: .utf8)
method on it:
if let stringValue = value as? String {
multipartFormData.append(stringValue.data(using: String.Encoding.utf8)!)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.