Junior — Middle
Is having a root view mandatory when initializing a ViewController?
sobes.tech AI
Answer from AI
Yes, when initializing a UIViewController, having a root view is mandatory. Each UIViewController manages a view hierarchy, starting with the root view (view property). If the root view is not set, the controller cannot properly display the interface or respond to events.
When creating a controller from a storyboard or xib, the root view is created automatically. If you create a controller programmatically, you should override loadView to set the view manually or use an initializer and assign the view afterward.