NotificationCenter.default.post не работает в замыканиях
У меня есть класс с наблюдателями уведомлений
NotificationCenter.default.addObserver(self, selector: #selector(self.methodOfReceivedNotification(notification:)), name: Notification.Name("Start"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.methodOfReceivedNotification(notification:)), name: Notification.Name("Stop"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.methodOfReceivedNotification(notification:)), name: Notification.Name("Interrupt"), object: nil)
В том же классе есть метод для обработки уведомления
@objc func methodOfReceivedNotification(notification: Notification) {
print("Notification Received")
}
Когда я пытаюсь отправить наблюдателя из другого класса с приведенным ниже кодом, он работает нормально
NotificationCenter.default.post(name: Notification.Name("Start"), object: nil)
Но при попытке опубликовать то же самое в ответе закрытия сетиметод, который он не вызывает methodOfReceivedNotification
Код закрытия
executeHttpReq(url: getUIUrl(), getparametersDict: getParameters, onSuccess: { (response, status,isEod) -> (
Any, String,Bool) in
NotificationCenter.default.post(name: Notification.Name("Start"), object: nil)
return (response,status,isEod)
}, onFailure: { (error) in
//todo send stop event to the caller
NotificationCenter.default.post(name: Notification.Name("Stop"), object: nil)
})
Есть ли какие-либо ошибки в коде, пожалуйста, предложите.