Reputation: 3
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"
}
}
Upvotes: 0
Views: 63
Reputation: 1816
Try changing
let postString = "type=" + jsonData["firstname"] + "&type=insert"
to
let postString = "type=" + test + "&type=insert"
since you are assigning the non-nil value to test
Let me know if this helps!
Upvotes: 1