Sunday, 25 August 2019

setting ids on item in Stackview

I have an array of object which I used to create a checkbox. The model has an id, name. I created a stackView to handle checkbox with id now I want to append items of selected checkbox to an array and be able to remove them when deselected. I am able to present all the views and it works well

below is my code

NetworkAdapter.instance.getFeaturesAmeneities()
            .subscribe(onNext: {feat in
                guard let data  = feat.data else {return}
                self.features.append(contentsOf: data)

                self.stackFeature.axis = .vertical
                self.stackFeature.distribution = .fill
                self.stackFeature.spacing = 8

                data.forEach {
                    print($0.id)
                    self.stv = CheckboxStackView()
                    self.stv?.label.text = $0.name
                    self.stv?.checkBox.tag = $0.id ?? 0
                    self.stackFeature.addArrangedSubview(self.stv!)
                }

            }).disposed(by: disposeBag)

Any help is appreciated



from setting ids on item in Stackview

No comments:

Post a Comment