ios - Issue with Swift 2 Error Handling -


i using rest json data , parse it. using nsjsonobjectwithdata, far i'm aware method used have error handler within parameters it's no longer there. in code here:

let err: nserror? let options:nsjsonreadingoptions = nsjsonreadingoptions.mutablecontainers var jsonresult = nsjsonserialization.jsonobjectwithdata(data!, options: options) as! nsdictionary; 

i error says:

"call can throw, not marked 'try' , error not handled"

how go fixing error?

here correct implementation,

do {     let jsondictionary = try nsjsonserialization.jsonobjectwithdata(data!, options: nsjsonreadingoptions.mutablecontainers) as! nsdictionary      //use dictionary here.     print("json : \(jsondictionary)") } catch  {     print(error)     //handle error. } 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -