Informs the observed object that the value of a given property is about to change.
SDKs
- iOS 2.0+
- macOS 10.3+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Foundation
Declaration
- (void)willChangeValueForKey:(NSString *)key;
Parameters
key
The name of the property that will change.
Discussion
Use this method when implementing key-value observer compliance manually to inform the observed object that the value at key
is about to change.
The change type of this method is NSKey
.
Important
After the values have been changed, a corresponding did
must be invoked with the same parameter.
Special Considerations
You rarely need to override this method in subclasses, but if you do, be sure to call super
.