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:
commit
8200c94fce
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
public protocol TemplateProtocol: AnyObject {
|
public protocol TemplateProtocol: AnyObject {
|
||||||
associatedtype TemplateModel: TemplateModelProtocol
|
associatedtype TemplateModel: TemplateModelProtocol
|
||||||
var templateModel: TemplateModel? { get set }
|
var templateModel: TemplateModel? { get set }
|
||||||
@ -19,6 +18,7 @@ public extension TemplateProtocol where Self: ViewController {
|
|||||||
guard let pageJSON = json else { return }
|
guard let pageJSON = json else { return }
|
||||||
let data = try JSONSerialization.data(withJSONObject: pageJSON)
|
let data = try JSONSerialization.data(withJSONObject: pageJSON)
|
||||||
let decoder = JSONDecoder()
|
let decoder = JSONDecoder()
|
||||||
|
try decoder.add(delegateObject: delegateObjectIVar)
|
||||||
let templateModel = try decoder.decode(TemplateModel.self, from: data)
|
let templateModel = try decoder.decode(TemplateModel.self, from: data)
|
||||||
self.templateModel = templateModel
|
self.templateModel = templateModel
|
||||||
self.pageModel = templateModel as? MVMControllerModelProtocol
|
self.pageModel = templateModel as? MVMControllerModelProtocol
|
||||||
|
|||||||
@ -17,7 +17,10 @@ import UIKit
|
|||||||
public var manager: (UIViewController & MVMCoreViewManagerProtocol)?
|
public var manager: (UIViewController & MVMCoreViewManagerProtocol)?
|
||||||
|
|
||||||
/// A temporary iVar backer for delegateObject() until we change the protocol
|
/// 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? {
|
public func delegateObject() -> DelegateObject? {
|
||||||
return delegateObjectIVar
|
return delegateObjectIVar
|
||||||
}
|
}
|
||||||
@ -264,9 +267,6 @@ import UIKit
|
|||||||
// Presents from the bottom.
|
// Presents from the bottom.
|
||||||
modalPresentationStyle = MVMCoreGetterUtility.isOnIPad() ? .formSheet : .overCurrentContext
|
modalPresentationStyle = MVMCoreGetterUtility.isOnIPad() ? .formSheet : .overCurrentContext
|
||||||
|
|
||||||
// Create the default delegate object.
|
|
||||||
delegateObjectIVar = MVMCoreUIDelegateObject.create(withDelegateForAll: self)
|
|
||||||
|
|
||||||
// Do some initial loading.
|
// Do some initial loading.
|
||||||
if !initialLoadFinished {
|
if !initialLoadFinished {
|
||||||
initialLoadFinished = true
|
initialLoadFinished = true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user