From 93f14fd2186b3ce568e3b78dbbb48d3e7e332582 Mon Sep 17 00:00:00 2001 From: Makeeyaf Date: Sat, 16 Jan 2021 20:53:20 +0900 Subject: [PATCH] =?UTF-8?q?bugfix:=20=EC=B2=AB=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=EB=8A=94=20=EB=AC=B4=EC=8B=9C=ED=95=B4=EC=84=9C=20?= =?UTF-8?q?=EB=B0=94=EC=9D=B8=EB=94=A9=EC=9D=B4=20=EB=A3=A8=ED=94=84?= =?UTF-8?q?=EC=97=90=20=EB=B9=A0=EC=A7=80=EC=A7=80=20=EC=95=8A=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BindingWithCell/Cell.swift | 2 +- BindingWithCell/CombineViewController.swift | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/BindingWithCell/Cell.swift b/BindingWithCell/Cell.swift index 6a7aabd..392f808 100644 --- a/BindingWithCell/Cell.swift +++ b/BindingWithCell/Cell.swift @@ -63,7 +63,7 @@ final class RxCell: UITableViewCell { final class CombineCell: UITableViewCell { static let reuseID = String(describing: self) - @Published var isOn: Bool = false + @Published var isOn: Bool = true // MARK: Views diff --git a/BindingWithCell/CombineViewController.swift b/BindingWithCell/CombineViewController.swift index bf63125..d6eb3ce 100644 --- a/BindingWithCell/CombineViewController.swift +++ b/BindingWithCell/CombineViewController.swift @@ -62,15 +62,14 @@ extension CombineViewController: UITableViewDelegate, UITableViewDataSource { cell.titleLabel.text = data[indexPath.row].title cell.toggleSwitch.isOn = data[indexPath.row].isOn - cell.$isOn.removeDuplicates() + cell.$isOn.dropFirst() + .removeDuplicates() .subscribe(on: DispatchQueue.main) .sink { [weak self] isOn in - print("Sink, \(isOn)") self?.data[indexPath.row].isOn = isOn self?.tableView.reloadData() } .store(in: &bag) - print("bag: \(bag.count)") return cell } }