Arrays 快速细胞填充

Arrays 快速细胞填充,arrays,swift,uitableview,Arrays,Swift,Uitableview,我想用数组中的数据填充tableview的单元格gists1 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! GistCell cell.back

我想用数组中的数据填充tableview的单元格gists1

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! GistCell
        cell.backgroundColor = .clear
        let gist = gists1[indexPath.row]
        cell.configure(with: gist)
        self.tableView.reloadData()
        return cell
    }
该单元格有一个自定义类

class GistCell: UITableViewCell {

    @IBOutlet weak var labelCell: UILabel!

    func configure(with gist: Gists) {
        self.labelCell.text = gist.description!
    }
}
这是阵列数据的转储:

 ▿ GistShowApp.Gists
    ▿ description: Optional("helloWorldDemo")
      - some: "helloWorldDemo"
    ▿ files: 1 key/value pair
      ▿ (2 elements)
        - key: "gistfile1.txt"
        ▿ value: GistShowApp.DetailGist
          ▿ filename: Optional("gistfile1.txt")
            - some: "gistfile1.txt"
          ▿ rawUrl: Optional("https://gist.githubusercontent.com/VladimirKhuraskin/c510014b85a6bdfa302f1f3837893a7c/raw/4648e701849ee7d52fb685111a7f0e4323505a35/gistfile1.txt")
            - some: "https://gist.githubusercontent.com/VladimirKhuraskin/c510014b85a6bdfa302f1f3837893a7c/raw/4648e701849ee7d52fb685111a7f0e4323505a35/gistfile1.txt"
我不太明白为什么先显示可选值,然后显示some值本身。
这可能是单元格中没有填充数据的原因?

我发现这一行是多余的

self.tableView.reloadData()

没有它,一切都能正常工作。

您需要学习如何展开。这是Swift的基本内容。对于文本没有出现的事实,您是否可以检查
self.labeCell
是否为零?以及它的
框架
中的配置(使用要点:)