From 2fa4f71d313128f6c58aa7e0d240889e15a510fa Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 9 Dec 2019 15:37:00 -0500 Subject: [PATCH 1/2] cool icon. --- MVMCoreUI/Models/Primitive Models/Color.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Models/Primitive Models/Color.swift b/MVMCoreUI/Models/Primitive Models/Color.swift index cafe5915..027b826e 100644 --- a/MVMCoreUI/Models/Primitive Models/Color.swift +++ b/MVMCoreUI/Models/Primitive Models/Color.swift @@ -18,7 +18,7 @@ public final class Color: Codable { public private(set) var hex: String = "" public private(set) var name: String = "" - // Color metadata + // Color metadata 🎨 public private(set) var red: CGFloat = 0 public private(set) var green: CGFloat = 0 public private(set) var blue: CGFloat = 0 From ce1559dc15216ed3a7151af08911daff42c2e3a9 Mon Sep 17 00:00:00 2001 From: panxi Date: Thu, 12 Dec 2019 17:28:02 -0500 Subject: [PATCH 2/2] add decode array method --- MVMCoreUI/Models/Extensions/ModelHelper.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MVMCoreUI/Models/Extensions/ModelHelper.swift b/MVMCoreUI/Models/Extensions/ModelHelper.swift index da5e0d56..b4d0b1e2 100644 --- a/MVMCoreUI/Models/Extensions/ModelHelper.swift +++ b/MVMCoreUI/Models/Extensions/ModelHelper.swift @@ -20,4 +20,15 @@ extension KeyedDecodingContainer where Key : CodingKey { public func decodeIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol? { return try decodeIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) } + + public func decodeArray(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeProtocol] { + guard let models = try decodeArray(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] else { + throw ModelRegistry.Error.decoderError + } + return models + } + + public func decodeArrayIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> [MoleculeProtocol]? { + return try decodeArrayIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) as? [MoleculeProtocol] + } }