"objcでKey-Value Observingしたいのだけど、observeValueForKeyPath:ofObject:change:contextメソッドでsuperを呼び出すのはどんなとき?" という話。 Key-Value Observingの方法とかは、他の方の分かりやすい記事を参照ください。 observeValueForKeyPath:ofObject:change:contextの書き方 Key-Value Observingするとき、監視する側はこのメソッドが呼ばれて通知される様子。 // NSKeyValueObserving Protocol - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(
Please note: this article is part of the older "Objective-C era" on Cocoa with Love. I don't keep these articles up-to-date; please be wary of broken code or potentially out-of-date information. Read "A new era for Cocoa with Love" for more. Here are five different ways to implement the Observer design pattern (sometimes called Broadcaster/Listener, Publish/Subscribe or Notifications) in Objective
Written by Mattt October 7th, 2013 This article has been translated into: 中文 Ask anyone who’s been around the NSBlock a few times: Key-Value Observing has the worst API in all of Cocoa. It’s awkward, verbose, and confusing. And worst of all, its terrible API belies one of the most compelling features of the framework. When dealing with complicated, stateful systems, dutiful book-keeping is essenti
We’ve discussed the importance of how events are communicated in APIs previously in our article on Key-Value Observing. This week, we’ll expand our look at the available options, with NSNotificationCenter & NSNotification. NSNotificationCenter provides a centralized hub through which any part of an application may notify and be notified of changes from any other part of the application. Observers
Notifications and KVO serve similar functions, but with different trade-offs. Notifications are easy to understand. KVO is... challenging... to understand (at least to understand how to use it well). Notifications require modification to the observed code. The observed must explicitly generate every notification it offers. KVO is transparent to the observed code as long as the observed code confor
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く