addObserver(_:toObjectsAt:forKeyPath:options:context:)
Registers an observer to receive key value observer notifications for the specified key-path relative to the objects at the indexes.
Declaration
func addObserver(_ observer: NSObject, toObjectsAt indexes: IndexSet, forKeyPath keyPath: String, options: NSKeyValueObservingOptions = [], context: UnsafeMutableRawPointer?)Parameters
- observer:
The observer.
- indexes:
The index set.
- keyPath:
The key path, relative to the array, to be observed.
- options:
The options to be included in the notification.
- context:
The context passed to the notifications.
Discussion
The options determine what is included in the notifications, and the context is passed in the notifications.
This is not merely a convenience method; invoking this method is potentially much faster than repeatedly invoking addObserver(_:forKeyPath:options:context:).