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 |
Distinguish between @synthesize and @dynamic in objective –c?
Will objective c be deprecated?
Is there function overloading in objective-c?
Does objective-c contain private strategies?
What is immutable infrastructure?
What is the difference between underscore and self (i.e self.xx and _xx) ?
How to reverse array in objective c?
Explain the difference between uiwindow and uiview?
What are the important data types found in objective-c?
Who calls dealloc method? Can we implement dealloc in arc?
How to use swift protocol in objective c?
What is the difference between a script and function?