0

I have this error on this piece of code, could any one tell me how can I change the this in Swift 2.0

if jsonResponse != nil {
  propertyListResponse = NSJSONSerialization.JSONObjectWithData(jsonResponse, 
    options: NSJSONReadingOptions.MutableLeaves,
    error: nil)
Ozgur Vatansever
  • 49,246
  • 17
  • 84
  • 119

1 Answers1

0

remove error in the paramater list

if jsonResponse != nil { propertyListResponse = try NSJSONSerialization.JSONObjectWithData( jsonResponse, options: NSJSONReadingOptions.MutableLeaves ) 
...
catch let error as NSError {
    // error handling
    print(error)
  }
}
Sahil
  • 9,096
  • 3
  • 25
  • 29
  • if jsonResponse != nil { propertyListResponse = NSJSONSerialization.JSONObjectWithData( jsonResponse, options: NSJSONReadingOptions.MutableLeaves) – Michael DC May 10 '16 at 04:43
  • Now I have this error: Call can throw, but it is not marked with 'try' and the error is not handled – Michael DC May 10 '16 at 04:44
  • check now updated answer. if an error occur then it throws that error so we need to handle that error with try catch. – Sahil May 10 '16 at 04:50
  • Problem solve thanks, this link is helpful too: https://gist.github.com/awaxman11/9c48c0b4c622bffb879f – Michael DC May 11 '16 at 00:36