View
open class View : IView
A Singleton 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.patterns.mediator.Mediator Mediator
@see org.puremvc.swift.patterns.observer.Observer Observer
@see org.puremvc.swift.patterns.observer.Notification Notification
-
Constructor.
This
IView
implementation is a Singleton, so you should not call the constructor directly, but instead call the static Singleton Factory methodView.getInstance()
@throws Error if Singleton instance has already been constructed
Declaration
Swift
public init()
-
Initialize the Singleton View instance.
Called automatically by the constructor, this is your opportunity to initialize the Singleton 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)
-
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
.