View
open class View : IView
A Multiton IView implementation.
In PureMVC, the View class assumes these responsibilities:
- Maintain a cache of
IMediatorinstances. - Provide methods for registering, retrieving, and removing
IMediators. - Notifiying
IMediatorswhen they are registered or removed. - Managing the observer lists for each
INotificationin the application. - Providing a method for attaching
IObserversto anINotification‘s observer list. - Providing a method for broadcasting an
INotification. - Notifying the
IObserversof a givenINotificationwhen 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
IViewimplementation 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
keymultitonKey
-
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
IObserversfor a particularINotification.All previously attached
IObserversfor thisINotification‘s list are notified and are passed a reference to theINotificationin the order in which they were registered.Declaration
Swift
open func notifyObservers(_ notification: INotification)Parameters
notificationthe
INotificationto notifyIObserversof. -
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
notificationNamewhich observer list to remove from
notifyContextremove the observer with this object as its notifyContext
-
Register an
IMediatorinstance with theView.Registers the
IMediatorso that it can be retrieved by name, and further interrogates theIMediatorfor itsINotificationinterests.If the
IMediatorreturns anyINotificationnames to be notified about, anObserveris created encapsulating theIMediatorinstance’shandleNotificationmethod and registering it as anObserverfor allINotificationstheIMediatoris interested in.Declaration
Swift
open func registerMediator(_ mediator: IMediator)Parameters
mediatora reference to the
IMediatorinstance -
Check if a Mediator is registered or not
Declaration
Swift
open func hasMediator(_ mediatorName: String) -> BoolParameters
mediatorNameReturn Value
whether a Mediator is registered with the given
mediatorName. -
Remove an IView instance
Declaration
Swift
open class func removeView(_ key: String)Parameters
multitonKeyof IView instance to remove
View Class Reference