I'm adding UIViewController in another UIView using:
self.addChild(vc)
self.view.addSubview(vc.view)
vc.didMove(toParent: self)
and removing that UIViewController by:
for childVC in self.children {
childVC.willMove(toParent: nil)
childVC.view.removeFromSuperview()
childVC.removeFromParent()
}
UIViewController remove from view but deinit of that UIViewController is not calling and it does not release memory of that UIViewController.
I'm not assigning any delegate to it that might cause strong reference cycle, what other thing I've to keep in mind to release it from memory too? Any other way?