Hi,
I don’t quite understand how the func post() is structured in Chapter 9. Can someone please explain how the “using” closure will be called in the viewDidLoaded() l later?
“extension Notification.Name {
// 1
static let acceptButton = Notification.Name(“acceptTapped”)
static let rejectButton = Notification.Name(“rejectTapped”)
// 2
func post(center: NotificationCenter = NotificationCenter.default,
object: Any? = nil,
userInfo: [AnyHashable : Any]? = nil) {
center.post(name: self, object: object, userInfo: userInfo)
}
// 3
@discardableResult
func onPost(center: NotificationCenter = NotificationCenter.default,
object: Any? = nil,
queue: OperationQueue? = nil,
using: @escaping (Notification) → Void)
→ NSObjectProtocol {
return center.addObserver(forName: self, object: object,
queue: queue, using: using)
}
}”
Thanks!
Mike