I'm trying to fetch data from my db but I have an exc_bad_instruction on my NSJSONSerialization.
func request(url:String, callback:(NSDictionary) -> ()){
let nsURL = NSURL(string: url)
let task = NSURLSession.sharedSession().dataTaskWithURL(nsURL!){
(data, response, error) in
//var error:NSError?
var response:NSDictionary
do{
response = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as! NSDictionary
callback(response)
}catch{
print("Something went wrong!")
}
}
task.resume()
}
Do you have any idea on why it's not working? Just to let you know something, I had to use the do, try, catch since Swift 2 because it was working great before!