diff --git a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift index 06660715..4fdff197 100644 --- a/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/TemplateProtocol.swift @@ -33,11 +33,7 @@ public extension TemplateProtocol { guard let pageJSON = json else { return } let delegateObject = (self as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject let data = try JSONSerialization.data(withJSONObject: pageJSON) - let decoder = JSONDecoder() - if let delegateObject = delegateObject { - // Add the delegate to access mid parsing if applicable. - try decoder.add(delegateObject: delegateObject) - } + let decoder = try JSONDecoder.create(delegateObject: delegateObjectIVar) templateModel = try decodeTemplate(using: decoder, from: data) // Add additional required behaviors if applicable. diff --git a/MVMCoreUI/TopAlert/TopNotificationModel.swift b/MVMCoreUI/TopAlert/TopNotificationModel.swift index 7c07c980..7d19bfcf 100644 --- a/MVMCoreUI/TopAlert/TopNotificationModel.swift +++ b/MVMCoreUI/TopAlert/TopNotificationModel.swift @@ -69,10 +69,7 @@ open class TopNotificationModel: Codable { /// Decodes the top alert json to a model. public static func decode(json: [AnyHashable: Any], delegateObject: MVMCoreUIDelegateObject?) throws -> Self { let data = try JSONSerialization.data(withJSONObject: json) - let decoder = JSONDecoder() - if let delegateObject = delegateObject { - try decoder.add(delegateObject: delegateObject) - } + let decoder = try JSONDecoder.create(delegateObject: delegateObject) return try decoder.decode(self, from: data) }