iOS Development UIKit Framework 2 — Questions and Answers
Question 1: What is the UIKit responder chain?
- The ordered sequence of objects that can handle touch or action events (Correct answer)
- The chain of view controllers in a navigation stack
- The delegate callback order for table views
- The sequence of lifecycle methods in a view controller
Correct answer: The ordered sequence of objects that can handle touch or action events
The responder chain is a series of linked responder objects that pass unhandled events up the hierarchy until one handles it.
Question 2: Which UIKit class manages navigation between a stack of view controllers?
- UINavigationController (Correct answer)
- UITabBarController
- UISplitViewController
- UIPageViewController
Correct answer: UINavigationController
UINavigationController manages a stack of view controllers and provides a navigation bar for moving between them.
Question 3: What is a storyboard in UIKit development?
- A visual file that represents the UI screens and transitions of an app (Correct answer)
- A JSON configuration file for layout constraints
- A collection of reusable UI components
- A script that automates UI testing
Correct answer: A visual file that represents the UI screens and transitions of an app
A storyboard is an Interface Builder file that lets you visually design your UI scenes and the segues connecting them.
Question 4: What is a UIKit delegate?
- An object that responds to events or customizes behavior on behalf of another object (Correct answer)
- A subclass that inherits all behavior from its parent
- A thread-safe wrapper around a UIView
- A property that stores a weak reference to self
Correct answer: An object that responds to events or customizes behavior on behalf of another object
The delegate pattern in UIKit allows one object to customize or respond to events of another object without subclassing.
Question 5: What does `@IBOutlet` do in a UIKit view controller?
- Creates a connection between a UI element in Interface Builder and a code property (Correct answer)
- Marks a property as optional
- Registers a view for Auto Layout
- Prevents deallocation of a view
Correct answer: Creates a connection between a UI element in Interface Builder and a code property
`@IBOutlet` marks a property so Interface Builder can wire it to a specific UI element, allowing code to reference it.
Question 6: Which method must be implemented to provide data for a UITableView?
- tableView(_:cellForRowAt:) (Correct answer)
- tableView(_:didSelectRowAt:)
- tableView(_:heightForRowAt:)
- tableView(_:titleForHeaderInSection:)
Correct answer: tableView(_:cellForRowAt:)
`tableView(_:cellForRowAt:)` is a required data source method that returns the configured cell for each row.
What is the UIKit responder chain?