I have this simple code:
let task = session.dataTaskWithRequest(request, completionHandler: {(data, response, error) in
print(response)
do {
let JSON = try NSJSONSerialization.JSONObjectWithData(data!, options:.AllowFragments)
// never printed
print(JSON)
guard let JSONDictionary :NSDictionary = (JSON as! NSDictionary) else {
print("Not a Dictionary")
retu
}
print("JSONDictionary! (JSONDictionary)")
}
catch let JSONError as NSError {
print("(JSONError)")
}
});
//
task.resume()
Well, I can read the response but then I get (lldb) and the app crashes. The line print(JSON) is never printed. I really can't understand what's going on, any tip is appreciated.
