Error: This property is defined but not available in this context

Error: This property is defined but not available in this context

我创建了一个包含 Sqlite 数据库字段的文件,但我无法从 tableView 访问属性

DataTableWord.swift

    class DataTableWord{
    
    var idWord: Int = 0
    var word: String = ""
    var features: String = ""
    var number: Int = 0
    
    init(idWord: Int, word: String, features: String, number: Int) {
        self.idWord = idWord
        self.word = word
        self.features = features
        self.number = number
    }

}

ViewController.swift

import UIKit

class ViewController: UIViewController, UITextViewDelegate, UITableViewDataSource {

var dataTableWord: [DataTableWord] = []

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataTableWord.count
    }

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

let cell = tableView.dequeueReusableCell(withIdentifier: "idCell1Main1", for: indexPath) as! TableViewCell

cell.cellLabelNumber.text = dataTableWord.[indexPath.row].idWord

return cell
    }


}

为什么会出现此错误消息?

idWord 的类型是 Intcell.cellLabelNumber.text 是字符串。你不能使这两种不同的东西相等。

改变

cell.cellLabelNumber.text = dataTableWord[indexPath.row].idWord

与:

cell.cellLabelNumber.text = "\(dataTableWord[indexPath.row].idWord)"