0

I updated Xcode to version 7 and tried reusing my old code:

let downloadTask : NSURLSessionDownloadTask = sharedSession.downloadTaskWithURL(dataURL!, completionHandler: { (location: NSURL?, response: NSURLResponse?, error: NSError?) -> Void in

let dataObject = NSData(contentsOfURL: location!)
let dataDictionary : NSDictionary = NSJSONSerialization.JSONObjectWithData(dataObject!, options: nil, error: nil) as NSDictionary
})

On the last line I'm now getting error: Extra argument 'error' in call

Though in the NSJSONSerialization Class reference the method contains the error argument.

I'm still kinda newbie in this, if someone can please explain me what's going on and how to solve this I will be very grateful.

Thanks in advance.

Orkhan Alizade
  • 7,379
  • 14
  • 40
  • 79
Dick Thunder
  • 378
  • 3
  • 17
  • 1
    Possible duplicate of [Swift: Extra argument 'error' in call](http://stackoverflow.com/questions/31073497/swift-extra-argument-error-in-call) – Bhavin Bhadani Oct 21 '15 at 08:54

1 Answers1

0

Try this:

let dataObject = NSData(contentsOfURL: location!)
do {
    let dataDictionary : NSDictionary = try NSJSONSerialization.JSONObjectWithData(dataObject!, options: []) as NSDictionary
} catch _ {
    dataObject = nil
}
Orkhan Alizade
  • 7,379
  • 14
  • 40
  • 79