如何计算金额加入购物车?

时间:2017-11-07 10:24:59

标签: swift3

我正在尝试计算所有产品的总产品价格。但前一个单元格没有加起来

enter image description here

代码:

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! AddChartTableViewCell
    cell.selectionStyle = .none
    let model = self.realm.objects(addCart.self)[indexPath.row]

    cell.chartBrand.text = model.name
    cell.chartPrice.text = model.productPrice

    let imageProctURL = model.chartImage
    cell.chartImage.sd_setImage(with: URL(string: imageProctURL!), placeholderImage: UIImage(named: "dummy"))

    stepper = KWStepper(decrementButton: cell.decrementButton, incrementButton: cell.incrementButton)


    stepper
        .maximumValue(100)
        .minimumValue(1)
        .stepValue(1)
        .valueChanged { [unowned self] stepper in
            var total = 0.0
            self.tempCount = stepper.value
            let prices  = (model.productPrice! as NSString).doubleValue
            let localTotal = prices * self.tempCount!
            total += (prices) * (self.tempCount)!
            print (" \(total)")

            self.subTotal.text = String(total)
    }

    return cell
}

如何获取刚离开屏幕的单元格值?

0 个答案:

没有答案