I'm trying to test in the Playground test if my view controllers are deallocated. In my app I want to have an external controller that presents the navigation controller that has another view controller as the child, and my dismissal code is directly in the child, which should propogate up to the navigation controller and then the sideMenu
controller. But neither controllers turn nil. Besides the instantiaion, I don't have any other references of the controllers, to my knowledge. What am I missing?
import UIKit
import PlaygroundSupport
class ViewController: UIViewController {
var num = 0
override func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {
print("dismissing")
super.dismiss(animated: flag, completion: completion)
}
deinit {
print("deinit view controller")
}
func logout1() {
dismiss(animated: false, completion: { print("logout1 ") })
}
// this doesn't work either
func logout2() {
navigationController?.dismiss(animated: false, completion: { print("logout2 ") })
}
}
var vc: ViewController? = ViewController()
var navController: UINavigationController? = UINavigationController(rootViewController: vc!)
let sideMenu = UIViewController()
sideMenu.present(navController!, animated: false, completion: nil)
vc?.logout2()
print(vc) // not nil
print(navController) // not nil