当我使用NotificationCenter发送通知时,之前打开的ViewController(具有不同的数据)响应我的通知。例如
A 到 B 的 x 数据 A 到 B 的 y 数据 A 到 B 的 z 数据
在这个场景之后(在B View Controller 中),当我推送通知时,通知观察者调用3次。
我使用 Storyboard 和以编程方式导航 Controller 。
最佳答案
您需要在 Bviewcontroller
中删除通知观察者,并在 Bviewcontroller
中添加以下方法
deinit {
NSNotificationCenter.defaultCenter().removeObserver(self)
}
关于ios - 在 Swift 中以编程方式完全杀死 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43069251/