Swift NotificationCenter remove observer quickest way

后端 未结 3 1339
陌清茗
陌清茗 2021-02-09 23:31

I am adding a number of observers in my viewController -- applicationWillResignActive, applicationDidEnterBackground, and many others. I w

3条回答
  •  终归单人心
    2021-02-09 23:48

    Yes

    NotificationCenter.default.removeObserver(self)
    

    this line is sufficient to remove the vc observation as long as all are added with

    NotificationCenter.default.addObserver
    

提交回复
热议问题