From 263e692bad4dff4cb0f4c1fd7058196bd01ef9cd Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 15 Aug 2022 09:14:18 -0500 Subject: [PATCH] retain cycle fix Signed-off-by: Matt Bruce --- .../CheckboxViewController.swift | 8 +++--- .../RadioButtonViewController.swift | 10 +++---- .../ToggleViewController.swift | 26 +++++++++---------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/VDSSample/ViewControllers/CheckboxViewController.swift b/VDSSample/ViewControllers/CheckboxViewController.swift index 7bce31a..096f1f8 100644 --- a/VDSSample/ViewControllers/CheckboxViewController.swift +++ b/VDSSample/ViewControllers/CheckboxViewController.swift @@ -142,10 +142,10 @@ class CheckboxViewController: UIViewController, StoryboardInitable { func setupPicker(){ picker.isHidden = true - surfacePicker.onPickerDidSelect = { item in - self.checkbox.surface = item - self.checkboxContainerView.backgroundColor = item.color - self.surfaceLabel.text = item.rawValue + surfacePicker.onPickerDidSelect = { [weak self] item in + self?.checkbox.surface = item + self?.checkboxContainerView.backgroundColor = item.color + self?.surfaceLabel.text = item.rawValue } } } diff --git a/VDSSample/ViewControllers/RadioButtonViewController.swift b/VDSSample/ViewControllers/RadioButtonViewController.swift index ae8b6b0..2a7ca70 100644 --- a/VDSSample/ViewControllers/RadioButtonViewController.swift +++ b/VDSSample/ViewControllers/RadioButtonViewController.swift @@ -31,8 +31,6 @@ class RadioButtonViewController: UIViewController, StoryboardInitable { @IBOutlet weak var childTextField: UITextField! @IBOutlet weak var showErrorSwitch: UISwitch! - // var radioButton: RadioButton! - // var radioButton2: RadioButton! var radioButtonGroup = RadioButtonGroup() public var model = DefaultRadioButtonGroupModel() public var subscribers = Set() @@ -150,10 +148,10 @@ class RadioButtonViewController: UIViewController, StoryboardInitable { func setupPicker(){ picker.isHidden = true - surfacePicker.onPickerDidSelect = { item in - self.radioButtonGroup.surface = item - self.componentContainerView.backgroundColor = item.color - self.surfaceLabel.text = item.rawValue + surfacePicker.onPickerDidSelect = { [weak self] item in + self?.radioButtonGroup.surface = item + self?.componentContainerView.backgroundColor = item.color + self?.surfaceLabel.text = item.rawValue } } } diff --git a/VDSSample/ViewControllers/ToggleViewController.swift b/VDSSample/ViewControllers/ToggleViewController.swift index a2349b6..4417321 100644 --- a/VDSSample/ViewControllers/ToggleViewController.swift +++ b/VDSSample/ViewControllers/ToggleViewController.swift @@ -112,25 +112,25 @@ class ToggleViewController: UIViewController, StoryboardInitable { func setupPicker(){ picker.isHidden = true - surfacePicker.onPickerDidSelect = { item in - self.toggle.surface = item - self.toggleContainerView.backgroundColor = item.color - self.surfaceLabel.text = item.rawValue + surfacePicker.onPickerDidSelect = { [weak self] item in + self?.toggle.surface = item + self?.toggleContainerView.backgroundColor = item.color + self?.surfaceLabel.text = item.rawValue } - fontWeightPicker.onPickerDidSelect = { item in - self.toggle.fontWeight = item - self.fontWeightLabel.text = item.rawValue + fontWeightPicker.onPickerDidSelect = { [weak self] item in + self?.toggle.fontWeight = item + self?.fontWeightLabel.text = item.rawValue } - textSizePicker.onPickerDidSelect = { item in - self.toggle.fontSize = item - self.textSizeLabel.text = item.rawValue + textSizePicker.onPickerDidSelect = { [weak self] item in + self?.toggle.fontSize = item + self?.textSizeLabel.text = item.rawValue } - textPositionPicker.onPickerDidSelect = { item in - self.toggle.textPosition = item - self.textPositionLabel.text = item.rawValue + textPositionPicker.onPickerDidSelect = { [weak self] item in + self?.toggle.textPosition = item + self?.textPositionLabel.text = item.rawValue } } }