| 1. |
What Is Kvc And Kvo? Give An Example Of Using Kvc To Set A Value.? |
|
Answer» KVC STANDS for Key-Value Coding. It's a mechanism by which an object's properties can be accessed using STRING's at RUNTIME rather than having to statically know the property names at development time. KVO stands for Key-Value Observing and allows a controller or class to OBSERVE changes to a property value. Let's SAY there is a property name on a class: @property (nonatomic, copy) NSString *name; We can access it using KVC: NSString *n = [object valueForKey:@"name"] And we can modify it's value by sending it the message: [object setValue:@"Mary" forKey:@"name"] KVC stands for Key-Value Coding. It's a mechanism by which an object's properties can be accessed using string's at runtime rather than having to statically know the property names at development time. KVO stands for Key-Value Observing and allows a controller or class to observe changes to a property value. Let's say there is a property name on a class: @property (nonatomic, copy) NSString *name; We can access it using KVC: NSString *n = [object valueForKey:@"name"] And we can modify it's value by sending it the message: [object setValue:@"Mary" forKey:@"name"] |
|