я получаю ошибку SIGABR для JSONSerialization ... вот код (XCode8)Swift: JSONSerialization SIGABRT ошибка
func makeHTTPPostRequest(path: String, body: String, onCompletion: @escaping ServiceResponse) {
var err: NSError?
let request = NSMutableURLRequest(url: NSURL(string: path)! as URL)
// Set the method to POST
request.httpMethod = "POST"
// Set the POST body for the request
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try! JSONSerialization.data(withJSONObject: body, options: [])
let session = URLSession.shared
let task = session.dataTask(with: request as URLRequest, completionHandler: {data, response, error -> Void in
let json:JSON = JSON(data: data!)
onCompletion(json, err)
})
task.resume()
}
Здесь значение переменной тела: { "Имя": "добавляет", "электронная почта ":" asd "," lastName ":" add "," password ":" asdas "}
Любая помощь будет принята с благодарностью!
Ошибка в JSONSerialization ... –