This commit is contained in:
Suresh, Kamlesh 2020-07-15 19:54:37 -04:00
parent 1698b21dd8
commit 724c1afd7c
3 changed files with 3 additions and 5 deletions

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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"
}
}
}