I am attempting to disconnect from a peripheral when ever a user leaves the current view controller. This would normally be easy by using prepare for segue in the following fashion:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
manager.cancelPeripheralConnection(peripheral)
}
This doesnt work, however; because the view controller is inside a container view. Does anybody know how to call this method when ever the container view is change from this view controller to a different one?
You could put it in func viewWillDisappear(_ animated: Bool)
or func viewDidDisappear(_ animated: Bool)
. Both will get called when the user navigates away from the view controller for any reason.