64 lines
1.9 KiB
Swift
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
|
|
// }
|
|
}
|