How do I join an array value to a string? I tried the following but got bad instruction error, appreciate any help. Sorry if my code looks bad as I'm still a student new to swift, hehe.
if let jsonData = try JSONSerialization.jsonObject(with: unwrappedData, options: .allowFragments) as? [String:Any] {
if let test = jsonData["firstname"] as? String {
let postString = "type=" + jsonData["firstname"] + "&type=insert"
}
}
jsonData["test"]conditionally bound totest, why do you use it, rather thantest?jsonData["firstname"] as? String, and you conditionally bound its result to the variabletest. But within thatif letblock, you usejsonData["firstname"], and not thetestvariable that you just bound