0 votes
11 views

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

in Technology by (190k points)

1 Answer

0 votes

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];

by (190k points)

Related questions

0 votes
1 answer 8 views
0 votes
1 answer 14 views
0 votes
1 answer 13 views
0 votes
1 answer 16 views
16 views asked Nov 10, 2020 in Technology by JackTerrance (190k points)
0 votes
1 answer 45 views
0 votes
1 answer 11 views
11 views asked Nov 7, 2020 in Education by Editorial Staff (49.4k points)
0 votes
1 answer 14 views
0 votes
1 answer 14 views
0 votes
1 answer 14 views
0 votes
1 answer 12 views
0 votes
1 answer 14 views
0 votes
1 answer 12 views
12 views asked Nov 10, 2020 in Technology by JackTerrance (190k points)
0 votes
1 answer 27 views
...