Key Value Coding-Key Value Observation

suggest change

Remarks

KVC :- Key-Value Coding

Normally instance variables are accessed through properties or accessors, but KVC gives another way to access variables as strings. In this way your class acts like a dictionary: a property name such as “age” is the key, and the value that property holds is the value for that key.

For example, an employee class has an age property stored as an NSNumber. Normally you access it like this:

emp.age = @20;
NSNumber *age = emp.age;

KVC uses the property name as a string:

[emp valueForKey:@"age"];
[emp setValue:@25 forKey:@"age"];

KVO :- Key-Value Observing

KVO notifies an object when a property changes. It is not a keyboard notification. For example, a person object can register for changes to accountBalance on a BankAccount by sending addObserver:forKeyPath:options:context:.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents