How do you convert this to a weak reference to self?
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(MyViewController.handleMessage(_:)), name: "NewMessage", object: nil)
NSNotificationCenter.defaultCenter().removeObserver(self, name: "NewMessage", object: nil)
Also, a related question--when does the view controller actually get destroyed? I'm assuming when you tab in and out of different views, view controllers still stay alive right? i.e. They don't get destroyed on viewDidDisappear.
this is the function in viewcontroller where it actually get out of the momory so here you can remove observer
and for making weak reference of self you can use