+2 votes
in C Plus Plus by
What is Key-Value-Coding and Key-Value-Observing in Objective-C?

1 Answer

0 votes
by

Key-Value-Coding (KVC) means accessing a property or value using a string.

id someValue = [myObject valueForKeyPath:@"foo.bar.baz"];

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:@"foo.bar.baz" options:0 context:NULL];

Related questions

+2 votes
asked Jan 19, 2022 in C Plus Plus by DavidAnderson
+1 vote
asked Jan 22, 2022 in Growth and Transformation by Robindeniel
...