views:

30

answers:

1

what are some of the popular use cases for using KVC and KVO? I'm not quite getting it.

Is it an objective C thing? or Cocoa thing? or a Coca Touch thing?

Can an iPhone app use KVC KVO?

Thanks!

p.s. I already read the doc here: http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html#//apple_ref/doc/uid/10000177i still puzzled.

+1  A: 

Normally, one refers to an object's properties by their variable name, which is what the compiler sees as well. However, if you don't know at compile time which property you'll be interested in at runtime, you can use KVC, because with KVC you can access properties by string (and key path). See this article: http://www.macresearch.org/cocoa_for_scientists_part_xi_the_value_in_keys

KVO allows you to be notified when a property changes. One use case is to keep a view in sync with the model. See: http://www.macresearch.org/cocoa_for_scientists_part_xii_observe_and_learn

Finally, Bindings is a way to describe where a view gets is data from and how to keep it in sync. Caveat: Bindings are not available in the iPhone SDK. But if you're programming for Mac OS X, see: http://www.macresearch.org/cocoa_for_scientists_part_xiii_in_a_bind

Joubert Nel
thank you! thank you!
Henry