try catch와 같은 모든 솔루션을 시도했습니다. 그러나이 오류를 해결할 수 없습니다. 제발 도와주세요, 나는 이오가 처음이에요.스위프트 3 : 추가 인수 'error'가 발생했습니다.
func apicalling() {
let headers = [
"content-type": "application/json",
"cache-control": "no-cache",
"postman-token": "7adebcbe-18b4-d2a7-2159-2fbcaea27edd"
]
let parameters = [
"customerID": "1",
"listType": "2"
]
let postData = JSONSerialization.dataWithJSONObject(parameters, options: nil, error: nil)
var request = NSMutableURLRequest(url: NSURL(string: "http://exp.php")! as URL,
cachePolicy: .useProtocolCachePolicy,timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.HTTPBody = postData
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
}
이 아래 줄에 오류 것은 :
let postData = JSONSerialization.dataWithJSONObject(parameters, options: nil, error: nil)
저를 도와주세요.
감사합니다. 빠른 3에서