I am currently developing my first iOS application using Swift 2.0 and Xcode Beta 2. It reads external JSON and generates a list in the form of a table with data. However, I get a strange little error that I cannot fix:
Extra argument 'error' in call
Here is a snippet of my code:
let task = session.dataTaskWithURL(url!, completionHandler: {data, response, error -> Void in print("Task completed") if(error != nil){ print(error!.localizedDescription) } var err: NSError? if let jsonResult = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &err) as? NSDictionary{ if(err != nil){ print("JSON Error \(err!.localizedDescription)") } if let results: NSArray = jsonResult["results"] as? NSArray{ dispatch_async(dispatch_get_main_queue(), { self.tableData = results self.appsTableView!.reloadData() }) } } })
The error is displayed on this line:
if let jsonResult = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &err) as? NSDictionary{
Can someone please tell me what I'm doing wrong here?
ios swift2 xcode7-beta2
kaanmijo Jun 26 '15 at 12:43 on 2015-06-26 12:43
source share