Model

open class Model : IModel

A Multiton IModel implementation.

In PureMVC, the Model class provides access to model objects (Proxies) by named lookup.

The Model assumes these responsibilities:

  • Maintain a cache of IProxy instances.
  • Provide methods for registering, retrieving, and removing IProxy instances.

Your application must register IProxy instances with the Model. Typically, you use an ICommand to create and register IProxy instances once the Facade has initialized the Core actors.

@see org.puremvc.swift.multicore.patterns.proxy.Proxy Proxy

@see org.puremvc.swift.multicore.interfaces.IProxy IProxy

  • Constructor.

    This IModel implementation is a Multiton, so you should not call the constructor directly, but instead call the static Multiton Factory method Model.getInstance( multitonKey )

    @throws Error if instance for this Multiton key instance has already been constructed

    Declaration

    Swift

    public init(key: String)

    Parameters

    key

    multitonKey

  • Initialize the Model instance.

    Called automatically by the constructor, this is your opportunity to initialize the Multiton instance in your subclass without overriding the constructor.

    Declaration

    Swift

    open func initializeModel()
  • Model Multiton Factory method.

    Declaration

    Swift

    open class func getInstance(_ key: String, factory: (String) -> IModel) -> IModel

    Parameters

    key

    multitonKey

    factory

    reference that returns IModel

    Return Value

    the instance returned by the passed closure

  • Register an IProxy with the Model.

    Declaration

    Swift

    open func registerProxy(_ proxy: IProxy)

    Parameters

    proxy

    an IProxy to be held by the Model.

  • Retrieve an IProxy from the Model.

    Declaration

    Swift

    open func retrieveProxy(_ proxyName: String) -> IProxy?

    Parameters

    proxyName

    Return Value

    the IProxy instance previously registered with the given proxyName.

  • Check if a Proxy is registered

    Declaration

    Swift

    open func hasProxy(_ proxyName: String) -> Bool

    Parameters

    proxyName

    Return Value

    whether a Proxy is currently registered with the given proxyName.

  • Remove an IProxy from the Model.

    Declaration

    Swift

    @discardableResult
    open func removeProxy(_ proxyName: String) -> IProxy?

    Parameters

    proxyName

    name of the IProxy instance to be removed.

    Return Value

    the IProxy that was removed from the Model

  • Remove an IModel instance

    Declaration

    Swift

    open class func removeModel(_ key: String)

    Parameters

    multitonKey

    of IModel instance to remove