Rodhos Soft

備忘録を兼ねた技術的なメモです。Rofhos SoftではiOSアプリ開発を中心としてAndroid, Webサービス等の開発を承っております。まずはご相談下さい。

NSNotificationCenterのまとめ


NSNotificationCenter Class Reference

より意訳

An NSNotificationCenter object (or simply, notification center) provides a mechanism for broadcasting information within a program. An NSNotificationCenter object is essentially a notification dispatch table.

NSNotificationCenterはブロードキャスティング機能を提供します。中身はnotificationのdispatch tableです。

Objects register with a notification center to receive notifications (NSNotification objects) using the addObserver:selector:name:object: or addObserverForName:object:queue:usingBlock: methods. Each invocation of this method specifies a set of notifications. Therefore, objects may register as observers of different notification sets by calling these methods several times.

オブジェクトはaddObserver:selector:name:object:かaddObserverForName:object:queue:usingBlock: を使って
センターに登録してNSNotificationを受け取ることができます。

Each running Cocoa program has a default notification center. You typically don’t create your own. An NSNotificationCenter object can deliver notifications only within a single program. If you want to post a notification to other processes or receive notifications from other processes, use an instance of NSDistributedNotificationCenter.


起動しているプログラムはデフォルトのセンターを持っています。なので一般にはセンターを作らなくてすみます。センターはNSNotificationをプログラムの範囲内でのみ通知できます。もし、他のプロセルに通知したり通知をもらいたい場合はNSDistributedNotificationCenterを使ってみてください。