From c00c0fb24d284b38589648f976fbb3743888f584 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 11 Aug 2022 09:50:53 -0500 Subject: [PATCH] updated init Signed-off-by: Matt Bruce --- VDS/Classes/Control.swift | 7 ++----- VDS/Classes/View.swift | 7 ++----- VDS/Components/Label/Label.swift | 7 ++----- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index 85a2bc44..ab01bdb1 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -12,7 +12,7 @@ import Combine open class Control: UIControl, ModelHandlerable, ViewProtocol, Resettable { - @Published public var model: ModelType + @Published public var model: ModelType = ModelType() public var cancellables = Set() open func shouldUpdateView(viewModel: ModelType) -> Bool { @@ -38,25 +38,22 @@ open class Control: UIControl, ModelHandlerable, ViewProto // MARK: - Initializers //-------------------------------------------------- required public init() { - self.model = ModelType() super.init(frame: .zero) initialSetup() } public required init(with model: ModelType) { - self.model = model super.init(frame: .zero) initialSetup() + set(with: model) } public override init(frame: CGRect) { - self.model = ModelType() super.init(frame: .zero) initialSetup() } public required init?(coder: NSCoder) { - self.model = ModelType.init() super.init(coder: coder) initialSetup() } diff --git a/VDS/Classes/View.swift b/VDS/Classes/View.swift index d7db4c7a..a58278f0 100644 --- a/VDS/Classes/View.swift +++ b/VDS/Classes/View.swift @@ -12,7 +12,7 @@ import Combine open class View: UIView, ModelHandlerable, ViewProtocol, Resettable { - @Published public var model: ModelType + @Published public var model: ModelType = ModelType() public var cancellables = Set() open func shouldUpdateView(viewModel: ModelType) -> Bool { @@ -38,25 +38,22 @@ open class View: UIView, ModelHandlerable, ViewProtocol, R // MARK: - Initializers //-------------------------------------------------- required public init() { - self.model = ModelType() super.init(frame: .zero) initialSetup() } public required init(with model: ModelType) { - self.model = model super.init(frame: .zero) initialSetup() + set(with: model) } public override init(frame: CGRect) { - self.model = ModelType() super.init(frame: .zero) initialSetup() } public required init?(coder: NSCoder) { - self.model = ModelType.init() super.init(coder: coder) initialSetup() } diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index 8d579eaf..907e1297 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -17,7 +17,7 @@ open class LabelBase: UILabel, ModelHandlerable, Initable //-------------------------------------------------- // MARK: - Combine Properties //-------------------------------------------------- - @Published public var model: ModelType + @Published public var model: ModelType = ModelType() public var cancellables = Set() //-------------------------------------------------- @@ -63,25 +63,22 @@ open class LabelBase: UILabel, ModelHandlerable, Initable // MARK: - Initializers //-------------------------------------------------- required public init() { - self.model = ModelType() super.init(frame: .zero) initialSetup() } public required init(with model: ModelType) { - self.model = model super.init(frame: .zero) initialSetup() } public override init(frame: CGRect) { - self.model = ModelType() super.init(frame: .zero) initialSetup() + set(with: model) } public required init?(coder: NSCoder) { - self.model = ModelType.init() super.init(coder: coder) initialSetup() }