NSNotificationCenter trapping and tracing all NSNotifications

前端 未结 5 649
傲寒
傲寒 2020-12-12 13:21

For some better understanding on what happens “under the hood”, I would love to do a complete trace of any notifications happening within my application.

Naïve as I

5条回答
  •  独厮守ぢ
    2020-12-12 13:57

    @Till solution in Swift 5.0 & Xcode 11:

    CFNotificationCenterAddObserver(
        CFNotificationCenterGetLocalCenter(),
        nil,
        { (notificationCenter, _, notificationName, _, dictionary) in
            print(notificationName)
            print(dictionary)
    }, nil, nil, .deliverImmediately)
    

提交回复
热议问题