【发布时间】:2017-05-05 16:03:12
【问题描述】:
import UIKit
import SwiftyJSON
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource{
@IBOutlet weak var tableView: UITableView!
var mass = [String]()
var jDatas = datas()
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: "https://www.quandl.com/api/v3/datasets/WIKI/AAPL.json")
let task = URLSession.shared.dataTask(with: url!) {(data, response, error) in
if error != nil {
print("error")
} else {
if let content = data {
let myJson = JSON(data: content)
for item in myJson["dataset"]["data"] {
let dates = "open \(String(describing: item.1[1].string)))"
self.mass.append(dates)
}
}
}
}
task.resume()
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return mass.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! SimpleTableViewCell
cell.datasLabel?.text = "some text"
return cell
}
}
所以我的问题是 numberOfRowInSection 不起作用,我尝试了所有方法,有人可以说是什么问题吗?
当我尝试调试代码时,它说我的海量中有 0
【问题讨论】:
标签: swift tableview swifty-json