如何快速将两个可变数组值相加?

时间:2019-07-04 10:27:28

标签: ios swift xcode

我有两个可变数组,其值来自文本字段。
在表单元格中,我的两个数组值都正确显示,但加法未执行。在添加两个可变数组时,它们显示错误二进制运算符+不能应用于两个Any操作数

这是我的代码

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
            let newCell = arr[indexPath.row] // They have value from textfield
            let newCell2 = arr2[indexPath.row] //They have value from textfield
            let addition = arr[indexPath.row] + arr2[indexPath.row]
            let cell = tableView.dequeueReusableCell(withIdentifier: "TableViewCell") as! TableViewCell
           cell.lblForEqual.text = "\(arr[indexPath.row]) + \(arr2[indexPath.row])"
            cell.lblForAdd.text = newCell as? String
            cell.lblForAdd2.text = newCell2 as? String
            cell.minusBtn.tag = indexPath.row
            cell.minusBtn.addTarget(self, action: #selector(minusButtonClicked(sender:)), for: .touchUpInside)


            return cell
    }

其他代码可以正常工作,但只能将两个可变数组相加。

0 个答案:

没有答案