Reputation: 8651
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
Upvotes: 0
Views: 329
Reputation: 3760
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)!)
}
Upvotes: 1