It seems you may be inadvertently passing the array self.gname
instead of a simple String
. From the context I have, I can’t tell if you’re trying to pass in an array or a string. Your code is making much too much use of the “no type” types, such as Any
and AnyObject
. You are explicitly disabling the safety and the helpfulness of the Swift type system.
I’d recommend changing your function declaration to indicate exactly what you need. Such as:
public func insertShot(_ rating: String, _ gname: String)
then within the body, you can change your dictionary declaration to
let param = [
"user" : reviewer,
"revieweduser" : gname,
"rating" : rating
]
Then drop the cast:
request.httpBody = createBodyWithParams(param, boundary: boundary)
You are passing in self.gname
which is an Array
of String
s. You need to pass in a String
.
Change you could to this:
if let gnameString = self.gname.first {
self.insertShot(“Yes”, gnameString)
}
Note: Your code is creating an array, you presumably need to figure out which value in the array you want to pass in.
8
solved Could not cast value of type ‘Swift.Array