Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.

Commit db42ec6

Browse files
committed
Fix crash on changing product quantity
1 parent bc2a2bb commit db42ec6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Samples/PagingLayoutSamples/Modules/Fruits/Cell/FruitsCollectionViewCell.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,11 @@ extension FruitsCollectionViewCell: QuantityControllerViewDelegate {
157157
// this is an example, in an ideal world we want to save the new quantity properly
158158

159159
func onDecreaseButtonTouched(view: QuantityControllerView) {
160-
viewModel?.quantity = max(0, (viewModel?.quantity ?? 0) - 1)
160+
let current = viewModel?.quantity ?? 0
161+
viewModel?.quantity = max(0, current - 1)
161162
}
162163
func onIncreaseButtonTouched(view: QuantityControllerView) {
163-
viewModel?.quantity = (viewModel?.quantity ?? 0) + 1
164+
let current = viewModel?.quantity ?? 0
165+
viewModel?.quantity = current + 1
164166
}
165167
}

0 commit comments

Comments
 (0)