Instance Method

addObserver:toObjectsAtIndexes: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

- (void)addObserver:(NSObject *)observer toObjectsAtIndexes:(NSIndexSet *)indexes forKeyPath:(NSString *)keyPath options:(NSKeyValueObservingOptions)options context:(void *)context;

Parameters

anObserver

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:.

See Also

Key-Value Observing

- removeObserver:forKeyPath:

Raises an exception.

- removeObserver:fromObjectsAtIndexes:forKeyPath:

Removes anObserver from all key value observer notifications associated with the specified keyPath relative to the array’s objects at indexes.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software