From c963c05f60eebc2021fa2fc97d48740c195ac0d7 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Wed, 20 Jan 2021 09:42:09 -0500 Subject: [PATCH] optional --- .../HorizontalCombinationViews/TabBarModel.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift index 9de2cd54..581b890e 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift @@ -60,7 +60,7 @@ public class TabBarModel: MoleculeModelProtocol { } public class TabBarItemModel: Codable { - var title: String + var title: String? var image: String var action: ActionModelProtocol @@ -70,7 +70,7 @@ public class TabBarItemModel: Codable { case action } - public init(with title: String, image: String, action: ActionModelProtocol) { + public init(with title: String?, image: String, action: ActionModelProtocol) { self.title = title self.image = image self.action = action @@ -78,14 +78,14 @@ public class TabBarItemModel: Codable { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - title = try typeContainer.decode(String.self, forKey: .title) + title = try typeContainer.decodeIfPresent(String.self, forKey: .title) image = try typeContainer.decode(String.self, forKey: .image) action = try typeContainer.decodeModel(codingKey: .action) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(title, forKey: .title) + try container.encodeIfPresent(title, forKey: .title) try container.encode(image, forKey: .image) try container.encodeModel(action, forKey: .action) }