BMViewController

open class BMViewController<View> : UIViewController where View : UIView, View : BMViewWithViewControllerAndViewModel

Overview

A BMViewController replaces the default UIViewController. It manages a single screen, and listen to the users interactions with it.

Refer to BMViewWithViewControllerAndViewModel to understand the architecture of a view.

The BMViewController gives you access to a rootView which is the view properly casted.

  • The rootView associated with the BMViewController.

    Declaration

    Swift

    public var rootView: View { get }
  • The latest ViewModel received by this BMViewController This should not be directly set. Please use update(to: View.VM).

    Declaration

    Swift

    public var viewModel: View.VM? { get set }
  • An more convenient initializer. Since we are not not using the storyboard

    Declaration

    Swift

    public init()
  • Required init.

    Declaration

    Swift

    required public init?(coder aDecoder: NSCoder)
  • Used to load the specific main view managed by this view controller.

    Declaration

    Swift

    override public func loadView()
  • Called after the controller'€™s view is loaded into memory.

    Declaration

    Swift

    override open func viewDidLoad()
  • Called when view about to layout subviews.

    Declaration

    Swift

    open override func viewWillLayoutSubviews()
  • Called everytime the VM needs to be updated. Should be called on the main Thread.

    Declaration

    Swift

    public func update(to newModel: View.VM)

    Parameters

    newModel

    The new ViewModel

  • Called just before the update, override point for subclasses.

    Declaration

    Swift

    open func willUpdate(new: View.VM?)
  • Called right after the update, override point for subclasses.

    Declaration

    Swift

    open func didUpdate(old: View.VM?)
  • Asks to setup the interaction with the managed view, override point for subclasses.

    Declaration

    Swift

    open func setupInteractions()

Containement