Skip to content

Instantly share code, notes, and snippets.

@helloworldsmart
Created April 25, 2017 06:36
Show Gist options
  • Select an option

  • Save helloworldsmart/6aaca08fdd2149bda92306f7814192f4 to your computer and use it in GitHub Desktop.

Select an option

Save helloworldsmart/6aaca08fdd2149bda92306f7814192f4 to your computer and use it in GitHub Desktop.
func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) {
do {
//JSON資料處理
let dataDic = try JSONSerialization.jsonObject(with: Data(contentsOf: location), options: JSONSerialization.ReadingOptions.mutableContainers) as! [String:[String:AnyObject]]
//依據先前觀察的結構,取得result對應中的results所對應的陣列
dataArray = dataDic["StationName"]!["Zh_tw"] as! [AnyObject]
//重新整理Table View
self.tableView.reloadData()
} catch {
print("Error!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment