Instance Method


Returns a Boolean that indicates whether the value specified by a given pointer is valid for the property identified by a given key.


- (BOOL)validateValue:(inout id  _Nullable *)ioValue forKey:(NSString *)inKey error:(out NSError * _Nullable *)outError;



A pointer to a new value for the property identified by inKey. This method may modify or replace the value in order to make it valid.


The name of one of the receiver's properties. The key must specify an attribute or a to-one relationship.


If validation is necessary and ioValue is not transformed into a valid value, upon return contains an NSError object that describes the reason that ioValue is not a valid value.

Return Value

A Boolean set to YES if the value pointed at by ioValue is valid for the property identified by inKey, or if the method is able to modify the value at ioValue to make it valid; otherwise NO.


The default implementation of this method searches the class of the receiver for a validation method whose name matches the pattern validate<Key>

:error:. If you define such a method for a property, the default implementation of validateValue:forKey:error: calls it when asked to validate the corresponding property, allowing your method to alter the input value if needed, and to determine the return value.

If no such method exists for a particular property, validateValue:forKey:error: returns YES. In other words, by default, the general validation call succeeds if you don't explicitly provide a validation method for the given property.

See Adding Validation in Key-Value Coding Programming Guide for more information.

See Also


- validateValue:forKeyPath:error:

Returns a Boolean that indicates whether the value specified by a given pointer is valid for a given key path relative to the receiver.

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