无法指定类型'字符串'的值输入' MyOrderTableViewCell'

时间:2017-11-02 04:06:51

标签: ios swift didselectrowatindexpath

我想点击基于ID的行

所以我声明了一个数组来存储ID:

var idenArr = [String]()  

在didSelectRowAt indexPath:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

        var cell = tableView.dequeueReusableCell(withIdentifier: "myOrderTableViewCell", for: indexPath as IndexPath) as! MyOrderTableViewCell
        cell = idenArr[indexPath.row] `<-- Here show me this error "Cannot assign value of type 'String' to type 'MyOrderTableViewCell'"`
}

1 个答案:

答案 0 :(得分:0)

为此,您可以通过以下方式获取:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let ID = idenArr[indexPath.row]
    print("Your selected Id is:" ID)
}