arowmy init works fine in Swift < 2 but in Swift 2 I get a error message from Xcode Call can throw, but it is not marked with \'try\' and the error is not handled>
JSONSerialization.JSONObject throws ErrorType and not NSError.
so the correct catch is
do {
let anyObj = try JSONSerialization.JSONObject(with: data, options: []) as! [String:AnyObject]
// use anyObj here
} catch let error {
print("json error: \(error)")
}
The type of error
in catch let error
is ErrorType