Merge branch 'feature/decoder_delegate' into 'develop'

delegate object for model decoding functions

See merge request BPHV_MIPS/mvm_core_ui!431
This commit is contained in:
Pfeil, Scott Robert 2020-05-12 09:21:13 -04:00
commit 8200c94fce
2 changed files with 5 additions and 5 deletions

View File

@ -8,7 +8,6 @@
import Foundation
public protocol TemplateProtocol: AnyObject {
associatedtype TemplateModel: TemplateModelProtocol
var templateModel: TemplateModel? { get set }
@ -19,6 +18,7 @@ public extension TemplateProtocol where Self: ViewController {
guard let pageJSON = json else { return }
let data = try JSONSerialization.data(withJSONObject: pageJSON)
let decoder = JSONDecoder()
try decoder.add(delegateObject: delegateObjectIVar)
let templateModel = try decoder.decode(TemplateModel.self, from: data)
self.templateModel = templateModel
self.pageModel = templateModel as? MVMControllerModelProtocol

View File

@ -17,7 +17,10 @@ import UIKit
public var manager: (UIViewController & MVMCoreViewManagerProtocol)?
/// A temporary iVar backer for delegateObject() until we change the protocol
public var delegateObjectIVar: MVMCoreUIDelegateObject?
public let delegateObjectIVar: MVMCoreUIDelegateObject = {
return MVMCoreUIDelegateObject.create(withDelegateForAll: self)
}()
public func delegateObject() -> DelegateObject? {
return delegateObjectIVar
}
@ -264,9 +267,6 @@ import UIKit
// Presents from the bottom.
modalPresentationStyle = MVMCoreGetterUtility.isOnIPad() ? .formSheet : .overCurrentContext
// Create the default delegate object.
delegateObjectIVar = MVMCoreUIDelegateObject.create(withDelegateForAll: self)
// Do some initial loading.
if !initialLoadFinished {
initialLoadFinished = true