30 lines
778 B
Swift
30 lines
778 B
Swift
//
|
|
// ModelTemplateProtocol.swift
|
|
// MVMCoreUI
|
|
//
|
|
// Created by Suresh, Kamlesh on 11/25/19.
|
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
public protocol TemplateProtocol {
|
|
var templateModel: TemplateModelProtocol? {get}
|
|
func parseTemplateJSON()
|
|
func templateData() -> Data?
|
|
}
|
|
|
|
extension TemplateProtocol where Self: MFViewController {
|
|
public func templateData() -> Data? {
|
|
guard let pageJSON = loadObject?.pageJSON as? [String: AnyHashable] else {
|
|
return nil
|
|
}
|
|
do {
|
|
return try JSONSerialization.data(withJSONObject: pageJSON)
|
|
} catch {
|
|
MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)")
|
|
return nil
|
|
}
|
|
}
|
|
}
|