I just converted my code to Swift 2.0 and it converted the code beautifully.
Just one thing I am not able to understand that how to use the try-catch in my codes.
I am posting the data and getting the JSON formatted
if anything goes wrong in network then it throws error and app crashes when JSON serialisation is done. How to prevent this, my code snap is below.
do {
json = try! NSJSONSerialization.JSONObjectWithData(data!, options: .MutableLeaves) as? NSDictionary
}
catch {
// report error
}
It crashed in the line
json = try! NSJSONSerialization.JSONObjectWithData(data!, options: .MutableLeaves) as? NSDictionary
How to use catch so that it does not crash here and shows error!!!