2
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不起作用,我试过一切,有人可以说最新的问题?Swift TableView不返回numbersOfRow
当我试图调试它说的代码,在那里有我的0大规模
TNX,它的工作),但现在,当我试图把我在大规模它的tableView说*开放无)* –
@SerjSemenov欢迎的队友,那是因为数组不包含字符串值,但数尝试像这样'let dates =“open \(String(item.1 [1] .doubleValue)))'' –
OMG我没有注意到,tnx很多) –