开发者

Key-Value Coding and Key-Value Observing use case?

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 u开发者_StackOverflow社区se 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜