mvm_core_ui/MVMCoreUI/Molecules/ModelMoleculeViewProtocol.swift
Pfeil, Scott Robert f5ed509a39 renaming
2020-01-21 15:33:27 -05:00

35 lines
1.6 KiB
Swift

//
// ModelMoleculeViewProtocol.swift
// MVMCoreUI
//
// Created by Suresh, Kamlesh on 10/24/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
public protocol ModelMoleculeViewProtocol {
func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?)
static func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String?
static func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat?
static func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]?
}
extension ModelMoleculeViewProtocol {
public static func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return model?.moleculeName
}
public static func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return nil
}
public static func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
return nil
}
// Temporary
public static func decodeJSONToModel<T>(json: [AnyHashable: Any], type: T.Type) throws -> T where T : Decodable {
let data = try JSONSerialization.data(withJSONObject: json)
let decoder = JSONDecoder()
return try decoder.decode(type, from: data)
}
}