From 724c1afd7c0f62a91a775ddd5819fb9c56eb3e5d Mon Sep 17 00:00:00 2001 From: "Suresh, Kamlesh" Date: Wed, 15 Jul 2020 19:54:37 -0400 Subject: [PATCH] fixes --- MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject+Swift.swift | 2 +- MVMCore/MVMCore/Models/ActionType/AlertModel.swift | 3 +-- .../MVMCore/Models/ActionType/UIAlertActionStyle+Codable.swift | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject+Swift.swift b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject+Swift.swift index e2cf018..46503fa 100644 --- a/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject+Swift.swift +++ b/MVMCore/MVMCore/AlertHandling/MVMCoreAlertObject+Swift.swift @@ -21,7 +21,7 @@ public extension MVMCoreAlertObject { var actionsForAlert: [UIAlertAction] = [] for actionJson in actionsList { - let style = UIAlertAction.Style(rawValue: Int(actionJson.int32ForKey("style"))) ?? UIAlertAction.Style.default + let style = UIAlertAction.Style.getStyle(for: actionJson.stringForkey("style")) let alertAction = UIAlertAction(title: actionJson.optionalStringForKey(KeyTitle), style: style) { (action) in MVMCoreActionHandler.shared()?.handleAction(with: actionJson.optionalDictionaryForKey("action"), additionalData: additionalData, delegateObject: delegateObject) } diff --git a/MVMCore/MVMCore/Models/ActionType/AlertModel.swift b/MVMCore/MVMCore/Models/ActionType/AlertModel.swift index 3f002e9..b0a348d 100644 --- a/MVMCore/MVMCore/Models/ActionType/AlertModel.swift +++ b/MVMCore/MVMCore/Models/ActionType/AlertModel.swift @@ -28,11 +28,10 @@ public class AlertButtonModel: Codable { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) title = try typeContainer.decode(String.self, forKey: .title) - + if let style = try? typeContainer.decodeIfPresent(String.self, forKey: .style) { self.style = UIAlertAction.Style.getStyle(for: style) } - action = try typeContainer.decodeModel(codingKey: .action) } diff --git a/MVMCore/MVMCore/Models/ActionType/UIAlertActionStyle+Codable.swift b/MVMCore/MVMCore/Models/ActionType/UIAlertActionStyle+Codable.swift index a461e82..4957cbc 100644 --- a/MVMCore/MVMCore/Models/ActionType/UIAlertActionStyle+Codable.swift +++ b/MVMCore/MVMCore/Models/ActionType/UIAlertActionStyle+Codable.swift @@ -12,7 +12,7 @@ enum AlertActionError: Error { case notAnAlertAction } -extension UIAlertAction.Style: RawRepresentable { +extension UIAlertAction.Style: Codable { public init(from decoder: Decoder) throws { let typeContainer = try decoder.singleValueContainer() @@ -79,5 +79,4 @@ extension UIAlertAction.Style: RawRepresentable { return "default" } } - }