What are kvc and kvo? Provide an example.
Answer / Bhaskar Narayan
In Objective-C, Key-Value Coding (KVC) and Key-Value Observing (KVO) are design patterns for dynamic runtime behavior. KVC allows you to access instance variables and call methods on objects using strings instead of fixed property names. KVO enables you to observe changes to an object's properties automatically. Here is a simple example of KVC: NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"John", @"name", @30, @"age", nil]; NSString *value; value = [dict objectForKey:@"name"]; // returns John. Example of KVO: You can observe changes to an object's properties using NSKeyValueObserving protocol.
| Is This Answer Correct ? | 0 Yes | 0 No |
How do I open .m files?
What are the attributes of category?
Is method and function same?
What happens if you add your just created object to a mutable array, and you release your object?
What are the delegate?
What is synthesized in objective-c?
What is the class of a constant string?
How can we put nil it into dictionary/array?
What is a goal and objective?
What is polymorphism in objective-c?
What is atomic property?
What is instancetype?