I'm new to RxSwift and I have this code to setup a tableview which contains a textfield:
budget.expenses.asObservable()
.bindTo(tableView.rx.items(cellIdentifier: ExpenseInputCell.cellIdentifier, cellType: ExpenseInputCell.self)){(row, element, cell) in
cell.name.text = element.name.value
cell.name.rx.text
.bindTo(element.name)
.addDisposableTo(self.disposeBag)
}
.addDisposableTo(disposeBag)
tableView.rx.itemDeleted
.subscribe(onNext: {indexPath in
self.budget.expenses.value.remove(at: indexPath.row)
})
.addDisposableTo(disposeBag)
Everything works fine until a row is deleted, because then the binding of the textfield to the correct object in the array is mixed up. For example lets say I have 7 items in the tableview and I delete the 5th row, the new 5th and 6th row both have the same value