我使用库格尔通知库(https://github.com/TakeScoop/Kugel/tree/swift-3.0)。我想知道如何删除Observer和我的代码中的哪个位置。我使用退订图书馆并没有任何反应移除观察者通知Swift 3
覆盖FUNC viewDidDisappear(_动画:BOOL){
super.viewDidDisappear(animated)
Kugel.unsubscribe("SleepMode")
Kugel.unsubscribe("SleepModeSynchroMode")
Kugel.unsubscribe(self, name: NSNotification.Name(rawValue: "SleepMode"), object: nil)
Kugel.unsubscribe(self, name: NSNotification.Name(rawValue: "SleepModeSynchroMode"), object: nil)
NotificationCenter.default.removeObserver(self, name: Notification.Name(rawValue: "SleepMode"), object: nil);
NotificationCenter.default.removeObserver(self, name: Notification.Name(rawValue: "SleepModeSynchroMode"), object: nil);
}
我想删除订阅通知(添加观察者),当我回到其他视图。 我使用denit {},但没有杀死的通知。
你能helpme
Tahnks
它应该工作,但请尽量将 - 优先FUNC viewDidDisappear(_动画:BOOL){ NotificationCenter.default.removeObserver(个体经营) } –