小编Ula*_*Ula的帖子

如何以正确的方式更新数组中的所有项目

有货币汇率的数组,并且在inputTextField中输入了金额之后,我想更新此货币上的该数组中的所有项目,并将该货币放在tableView中,尝试使用循环来执行此操作,但这不能正常工作,因为这是解决方案刚刚放在表中的每个循环

inputTextField是文本字段的名称

receivedRates:[Double] = [1.1,1.6,2.0,1.3] // just example of the rates

for i in receivedRates {

    let newValue = Double(i)*Double(Int(inputTextField.text!)!)
    currentAmount.append(newValue)
    receivedRates = currentAmount
}
Run Code Online (Sandbox Code Playgroud)

如何不循环地更新此数组,或者可能对此循环有其他解决方案?

arrays items insert-update ios swift

2
推荐指数
2
解决办法
2297
查看次数

标签 统计

arrays ×1

insert-update ×1

ios ×1

items ×1

swift ×1