对tableview有一些问题。 JSon内容的顺序是正确的,但是当我在问题开始时更新表格时。这是我更新表格的方式:
var cats = [Categories]()
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
cats.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cellIdentifier = "CategoryTableViewCell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! CategoryTableViewCell
print(cats[indexPath.row].categoryName)
cell.nameLabel.text = cats[indexPath.row].categoryName
cell.subNameLabel.text = cats[indexPath.row].appShortDesc
return cell
}
当我打印JSon时,它显示正确的顺序,只是tableview继续做它的感觉。