I can answer you is very easy.
addSubview : It is a method to add a View
to another View
as daughters.
addChildViewController : It is a method to add ViewController
to other ViewController
as children as the name suggests.
There is a big difference. When you for example instances something like this:
let viewController = UIViewController()
You are calling the method init()
but the view is not starting or loadView
Then you are creating a% co_of% empty.
The way to do it correctly is as follows:
let viewController = UIViewController()
parentViewController.addChildViewController(viewController) //Aquí se forma la vista y ya puedes acceder a viewController.view y no es nil
parentViewController.view.addSubview(viewController.view) //Aquí añades la vista