Junior — Middle
Can you explain the role of the rootViewController object in UIWindow and how it is used in iOS applications?
sobes.tech AI
Answer from AI
In iOS applications, the rootViewController object is the root view controller (UIViewController) that manages the main content of the window (UIWindow).
When the application launches, the UIWindow displays content managed by this controller. All other controllers are usually added or shown on top of the rootViewController.
Example of usage:
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = UINavigationController(rootViewController: MainViewController())
window?.makeKeyAndVisible()
Here, rootViewController sets the initial screen of the application. It is responsible for displaying the interface and handling user interactions at the top level.