View
open class View : IView
A Multiton IView
implementation.
In PureMVC, the View
class assumes these responsibilities:
- Maintain a cache of
IMediator
instances. - Provide methods for registering, retrieving, and removing
IMediators
. - Notifiying
IMediators
when they are registered or removed. - Managing the observer lists for each
INotification
in the application. - Providing a method for attaching
IObservers
to anINotification
‘s observer list. - Providing a method for broadcasting an
INotification
. - Notifying the
IObservers
of a givenINotification
when it broadcast.
@see org.puremvc.swift.multicore.patterns.mediator.Mediator Mediator
@see org.puremvc.swift.multicore.patterns.observer.Observer Observer
@see org.puremvc.swift.multicore.patterns.observer.Notification Notification
-
Constructor.
This
IView
implementation is a Multiton, so you should not call the constructor directly, but instead call the static Multiton Factory methodView.getInstance( multitonKey )
@throws Error if instance for this Multiton key has already been constructed
Declaration
Swift
public init(key: String)
Parameters
key
multitonKey
-
Initialize the Multiton View 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 initializeView()
-
Notify the
IObservers
for a particularINotification
.All previously attached
IObservers
for thisINotification
‘s list are notified and are passed a reference to theINotification
in the order in which they were registered.Declaration
Swift
open func notifyObservers(_ notification: INotification)
Parameters
notification
the
INotification
to notifyIObservers
of. -
Remove the observer for a given notifyContext from an observer list for a given Notification name.
Declaration
Swift
open func removeObserver(_ notificationName: String, notifyContext: AnyObject)
Parameters
notificationName
which observer list to remove from
notifyContext
remove the observer with this object as its notifyContext
-
Register an
IMediator
instance with theView
.Registers the
IMediator
so that it can be retrieved by name, and further interrogates theIMediator
for itsINotification
interests.If the
IMediator
returns anyINotification
names to be notified about, anObserver
is created encapsulating theIMediator
instance’shandleNotification
method and registering it as anObserver
for allINotifications
theIMediator
is interested in.Declaration
Swift
open func registerMediator(_ mediator: IMediator)
Parameters
mediator
a reference to the
IMediator
instance -
Check if a Mediator is registered or not
Declaration
Swift
open func hasMediator(_ mediatorName: String) -> Bool
Parameters
mediatorName
Return Value
whether a Mediator is registered with the given
mediatorName
. -
Remove an IView instance
Declaration
Swift
open class func removeView(_ key: String)
Parameters
multitonKey
of IView instance to remove