From 478498a9b66a8920419f0ed4cb5e519cd48d6c66 Mon Sep 17 00:00:00 2001 From: panxi Date: Wed, 13 Nov 2019 18:02:40 -0500 Subject: [PATCH] Separate action and molecule name --- MVMCoreUI/Models/Extensions/ModelHelper.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Models/Extensions/ModelHelper.swift b/MVMCoreUI/Models/Extensions/ModelHelper.swift index 1f15274f..c56a0a5a 100644 --- a/MVMCoreUI/Models/Extensions/ModelHelper.swift +++ b/MVMCoreUI/Models/Extensions/ModelHelper.swift @@ -11,12 +11,15 @@ import Foundation extension KeyedDecodingContainer where Key : CodingKey{ + private enum TypeCodingKey: String, CodingKey { + case moleculeName + } public func decode(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol { - return try decode(codingKey: codingKey, typeCodingKey: .moleculeName) + return try decode(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) } public func decodeIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol? { - return try decodeIfPresent(codingKey: codingKey, typeCodingKey: .moleculeName) + return try decodeIfPresent(codingKey: codingKey, typeCodingKey: TypeCodingKey.moleculeName) } }