私たちが送信したかどうかを知るためのコールバック方法は、オブザーバによって受信されたnotification
です。
我々はXcodeで取得することができますNotification Center
方法によると:
/**************** Notification Center ****************/
open class NotificationCenter : NSObject {
open class var `default`: NotificationCenter { get }
open func addObserver(_ observer: Any, selector aSelector: Selector, name aName: NSNotification.Name?, object anObject: Any?)
open func post(_ notification: Notification)
open func post(name aName: NSNotification.Name, object anObject: Any?)
open func post(name aName: NSNotification.Name, object anObject: Any?, userInfo aUserInfo: [AnyHashable : Any]? = nil)
open func removeObserver(_ observer: Any)
open func removeObserver(_ observer: Any, name aName: NSNotification.Name?, object anObject: Any?)
@available(iOS 4.0, *)
open func addObserver(forName name: NSNotification.Name?, object obj: Any?, queue: OperationQueue?, using block: @escaping (Notification) -> Swift.Void) -> NSObjectProtocol
}
そして、我々はNotificationCenter
のapple docsを参照することができ、我々はその機能を学ぶべきである:
オブジェクトの通知に登録addObserver(_:selector:name:object :)メソッドまたはaddObserver(forName:object:queue:using :)メソッドを使用して通知(NSNotificationオブジェクト)を受信することができます。
そして、docsからあなたの要件に関する記載が見つかりません。
通知のブロードキャストではなく、直接委任を調べたいと思うようなデザインの音が聞こえてきます。私は通知を「火の玉」と思うでしょう。 – luk2302
あなたは正しいです、質問を編集しました。 – wp42