无法调用非函数类型“ [String]”的值

时间:2019-03-10 16:09:14

标签: arrays swift string uitableview cell

我想将原型单元格中的标签文本设置为存储在数组中的字符串。

+-..-+

数组如下:

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "unitOptionCell", for: indexPath)

    cell.textLabel?.text = currentConvertion.availableUnits(indexPath)

    return cell
}

错误在哪里?

1 个答案:

答案 0 :(得分:1)

如果使用括号,则编译器会解释您正在尝试调用一个函数。您应该使用方括号来访问数组的元素,例如:

cell.textLabel?.text = currentConvertion.availableUnits[indexPath.row]