in Technology by (1.8m points)

What is KVC and KVO? Give an example of using KVC to set value.

1 Answer

0 votes
by (1.8m points)

Key-Value-Coding (KVC) means accessing a property or value using a string. id someValue = [myObject valueForKeyPath:@””];

Which could be the same as:

id someValue = [[[myObject foo] bar] baz];

Key-Value-Observing (KVO) allows you to observe changes to a property or value.

To observe a property using KVO you would identify to property with a string; i.e., using KVC. Therefore, the observable object must be KVC compliant.

[myObject addObserver:self forKeyPath:@”” options:0 context:NULL];

Related questions

0 votes
asked Jun 13, 2021 in Education by Editorial Staff (55.8k points)