var err: NSError?
var json = JSONSerialization.JSONObjectWithData(data!, options: .MutableContainers, error: &err) as? NSDictionary
it shows the error in 2nd line as "Extra argument 'error' in call"
var err: NSError?
var json = JSONSerialization.JSONObjectWithData(data!, options: .MutableContainers, error: &err) as? NSDictionary
it shows the error in 2nd line as "Extra argument 'error' in call"
You should check firstly if the error occurs instead of making serialization
do {
let jsonObject = try JSONSerialization.jsonObject(with: jsonData)
guard let dictionary = jsonObject as? Dictionary<String, Any> else {
print("Not a Dictionary")
// put in function
return
}
print("JSON Dictionary! \(dictionary)")
}
catch let error as NSError {
print("Found an error - \(error)")
}