mvm_core_ui/MVMCoreUI/Models/BaseModel.swift
Suresh, Kamlesh eb3b1a0e81 initial
2019-09-11 11:05:57 -04:00

64 lines
1.9 KiB
Swift

//
// BaseModel.swift
// MVMCoreUI
//
// Created by Suresh, Kamlesh on 9/10/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
public class BaseModel: Codable {
public var moleculeName: String?
// public var dictionaryRepresentation: [AnyHashable: Any]
private enum CodingKeys : String, CodingKey {
case moleculeName
}
public required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
moleculeName = try container.decode(String.self, forKey: CodingKeys.moleculeName)
}
public func encode(to encoder: Encoder) throws {
//try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(moleculeName, forKey: .moleculeName)
}
// //init
// public init(_ dictionary:[AnyHashable: Any]){
// dictionaryRepresentation = dictionary
// }
//
// public func getString(_ key:String) -> String {
// return dictionaryRepresentation[key] as? String ?? ""
// }
//
// public func getOptionalString(_ key:String) -> String? {
// return dictionaryRepresentation[key] as? String ?? nil
// }
//
// public func dictionaryForKey(_ key : String) -> [String : Any]? {
// let dict = dictionaryRepresentation.dictionaryForKey(key)
// if dict.count > 0 {
// return dict
// }
// return nil
// }
//
// public func arrayForKey(_ key : String) -> Array<Dictionary<AnyHashable, Any>>? {
// return dictionaryRepresentation.arrayForKey(key) as? Array<Dictionary<AnyHashable, Any>>
// }
//
// public func convertStringToBool(_ string:String)-> Bool{
// var converter = dictionaryRepresentation[string] as? String ?? ""
// converter = converter.lowercased()
// let convertedValue = converter == "true" || converter == "yes"
// return convertedValue
// }
}