私はJSONSerializationためSIGABRエラーを取得...ここにここでは、コード(XCode8)スウィフト: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()
}
は体変数の値である:{ "firstNameのは、": "追加"、 "電子メール":" asd "、" lastName ":" add "、" password ":" asdas "}
ご協力いただければ幸いです。あなたはSWIFT 3.0
let dataTsked = session.dataTask(with: URL(string: path)!) { (data, response, error) in
if (error != nil) {
する必要があります... –