Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
The root-view-controller initializer creates the navigation stack with homeController as its first screen.
Question 24 of 60 · Concept of auto-layout · Medium
A button must remain 20 points from the trailing edge of its container in both portrait and landscape orientations. Which constraint best achieves this?
Constraining the trailing anchors with a -20 constant keeps the button 20 points inside the container's trailing edge.
Question 25 of 60 · Concept of auto-layout · Medium
A label with variable text should expand horizontally before a nearby button is compressed. Which Auto Layout setting should be adjusted?
Not quite. Try another option.
Answer: Give the label a lower content-hugging priority
A lower content-hugging priority allows the label to grow beyond its intrinsic content width when extra space is available.
Question 26 of 60 · Concept of auto-layout · Medium
A programmatically created view ignores its anchor constraints and keeps an autoresizing-mask-based frame. What change is required?
Not quite. Try another option.
Answer: Set translatesAutoresizingMaskIntoConstraints to false
Disabling translatesAutoresizingMaskIntoConstraints prevents the autoresizing mask from generating constraints that conflict with explicit anchors.
Question 27 of 60 · Playing audio and video files · Medium
An application needs to play a short local audio file and provide direct controls for play, pause, and volume. Which class is most appropriate?
Not quite. Try another option.
Answer: AVAudioPlayer
AVAudioPlayer is designed for playing local audio files and provides playback, timing, looping, and volume controls.
Question 28 of 60 · Playing audio and video files · Medium
A developer creates an AVAudioPlayer for a local file, but no sound is produced because playback was never initialized. Which sequence should be used?
Not quite. Try another option.
Answer: Call prepareToPlay() and then play()
prepareToPlay() prepares the audio resources, and play() starts playback.
Question 29 of 60 · Playing audio and video files · Medium
An application must stream a remote video and display standard playback controls. Which combination is appropriate?
Not quite. Try another option.
Answer: AVPlayer with AVPlayerViewController
AVPlayer supports remote media playback, while AVPlayerViewController supplies a standard video interface and controls.
Question 30 of 60 · Implementing UICollectionView · Medium
A collection view cell appears with old content while scrolling because cells are reused. Where should the cell's labels and images normally be assigned?
Not quite. Try another option.
Answer: Inside collectionView(_:cellForItemAt:)
Each dequeued cell should be fully configured in cellForItemAt so reused content is replaced with data for the current index path.
Question 31 of 60 · Implementing UICollectionView · Medium
After inserting an item into a collection view's data source, which update correctly keeps the interface synchronized?
Not quite. Try another option.
Answer: Insert the model item, then call insertItems(at:)
The data source must be updated first, followed by insertItems(at:) for the corresponding index path.
Question 32 of 60 · Implementing UICollectionView · Medium
A collection view uses UICollectionViewFlowLayout. Which delegate method can provide a different size for each item?
Not quite. Try another option.
Answer: collectionView(_:layout:sizeForItemAt:)
The flow-layout delegate method sizeForItemAt determines the dimensions of each item at a given index path.
Question 33 of 60 · Implementing UIToolbar · Medium
A toolbar needs Save aligned left and Delete aligned right. Which item should be placed between the two buttons?
Not quite. Try another option.
Answer: A flexible-space bar button item
A flexible-space item expands to fill available space, pushing the surrounding buttons toward opposite ends.
Question 34 of 60 · Implementing UIToolbar · Medium
A UIToolbar has been created programmatically with three bar button items. Which property should receive those items?
Not quite. Try another option.
Answer: toolbar.items
A toolbar displays an array of UIBarButtonItem objects assigned through its items property.
Question 35 of 60 · UITabBar in applications · Medium
An application has Home, Search, and Settings sections, each requiring its own navigation history. What hierarchy is most appropriate?
Not quite. Try another option.
Answer: A tab bar controller containing three navigation controllers
Each tab can contain a separate navigation controller, allowing every section to maintain its own navigation stack.
Question 36 of 60 · UITabBar in applications · Medium
A developer wants the Settings tab to be selected when the application first displays its three tabs. Which property should be set to 2?
Not quite. Try another option.
Answer: selectedIndex
selectedIndex uses zero-based indexing, so a value of 2 selects the third tab.
Question 37 of 60 · UITabBar in applications · Medium
Which configuration adds a visible title and system icon to a view controller displayed by a tab bar controller?
Not quite. Try another option.
Answer: Assign a configured UITabBarItem to tabBarItem
Each child view controller uses its tabBarItem property to define the title, image, and badge shown in the tab bar.
Question 38 of 60 · Database using SQLite · Medium
A query must find a user by an email address supplied through a text field. Which approach best reduces the risk of SQL injection?
Not quite. Try another option.
Answer: Use a prepared statement with a bound parameter
Prepared statements keep user data separate from SQL syntax and safely bind the email as a parameter.
Question 39 of 60 · Database using SQLite · Medium
Several related SQLite updates must either all succeed or all be undone. Which SQL commands should surround the updates?
Not quite. Try another option.
Answer: BEGIN TRANSACTION and COMMIT
A transaction groups related updates. Use COMMIT after success or ROLLBACK if any update fails.
Question 40 of 60 · Database using SQLite · Medium
An SQLite query has been prepared with sqlite3_prepare_v2. Which return value from sqlite3_step indicates that a row of result data is available?
Not quite. Try another option.
Answer: SQLITE_ROW
SQLITE_ROW means a result row is available for reading. SQLITE_DONE means execution completed without another row.
Question 41 of 60 · Using navigation controllers · Hard
A view controller pushed onto a UINavigationController needs to animate a custom subview alongside both interactive and noninteractive pop transitions. Which approach correctly keeps the animation synchronized and handles cancellation?
Not quite. Try another option.
Answer: Register the animation with the current transitionCoordinator and inspect the completion context
The transition coordinator synchronizes custom animations with the navigation transition. Its completion context reports whether an interactive transition was cancelled.
Question 42 of 60 · Using navigation controllers · Hard
After assigning a custom object as a navigation controller's interactivePopGestureRecognizer.delegate, the edge-swipe gesture intermittently stops working. What is the most robust correction?
Not quite. Try another option.
Answer: Avoid replacing the system gesture delegate and coordinate conflicts through gesture-recognizer APIs
The system delegate participates in UIKit's interactive transition machinery. Replacing it can break gesture-driven pops; conflicts should be handled without taking over that private coordination role.
Question 43 of 60 · Using navigation controllers · Hard
A navigation controller is restoring a deep stack [A, B, C] without animation. The current stack is [A, X]. Which operation replaces the entire stack atomically while preserving normal containment callbacks?
setViewControllers(_:animated:) is the supported API for replacing a navigation stack and lets UIKit perform the required parent-child containment updates.
Question 44 of 60 · Concept of auto-layout · Hard
A horizontal stack contains a label and a text field. Both have enough constraints to determine their positions. When space becomes limited, the label must remain at intrinsic width and the text field should shrink first. Which priority change directly expresses this rule?
Not quite. Try another option.
Answer: Give the label higher horizontal compression resistance than the text field
Compression resistance controls which view resists becoming narrower than its intrinsic width. A higher label priority causes the text field to compress first.
Question 45 of 60 · Concept of auto-layout · Hard
A scroll view fills its parent. Its content view is constrained on all four edges to contentLayoutGuide and has equal width to frameLayoutGuide. The content view has no explicit height, but its vertically arranged subviews form an unbroken top-to-bottom constraint chain. What behavior results?
Not quite. Try another option.
Answer: Vertical scrolling works when the inferred content height exceeds the frame
The edge constraints and vertical chain infer content height. Equal width to the frame guide prevents horizontal scrolling while allowing vertical overflow.
Question 46 of 60 · Concept of auto-layout · Hard
A view's horizontal position and width are fully determined, but its vertical constraints specify only a fixed height and centerY. Interface Builder still reports an ambiguous layout at runtime. Which statement is correct?
Not quite. Try another option.
Answer: The vertical layout is determined, so the ambiguity must originate elsewhere
A fixed height plus a vertical center uniquely determines the top and bottom coordinates. Auto Layout does not require edge constraints when equivalent independent constraints exist.
Question 47 of 60 · Playing audio and video files · Hard
A spoken-audio app should pause when an interruption begins and resume only if playback was active beforehand and the interruption options indicate that resumption is appropriate. Which design is correct?
Not quite. Try another option.
Answer: Record the prior playback state, pause on .began, and conditionally resume on .ended with .shouldResume
Interruption handling must preserve user intent. .shouldResume is relevant only at interruption end and should be combined with the app's recorded pre-interruption state.
Question 48 of 60 · Playing audio and video files · Hard
An app loops a local video by observing AVPlayerItem.didPlayToEndTimeNotification. It later replaces player.currentItem, but looping stops. What is the most likely cause?
Not quite. Try another option.
Answer: The observer was filtered to the old player item and was not registered for the replacement
The notification's object is the AVPlayerItem. An observer registered with the old item as its object will not receive end notifications from the new item.
Question 49 of 60 · Playing audio and video files · Hard
A music app must continue playing when the screen locks and should mix with audio from another app at a reduced relative volume. Which audio-session configuration best matches the requirement?
Not quite. Try another option.
Answer: Use .playback with .mixWithOthers, plus the Audio background mode
The .playback category supports lock-screen playback, .mixWithOthers permits simultaneous external audio, and the Audio background mode permits continued execution for playback.
Question 50 of 60 · Implementing UICollectionView · Hard
A collection view currently displays 5 items. Inside performBatchUpdates, the code deletes item 1 and inserts a new item at index 4. What must the data source report when UIKit validates the completed update?
Not quite. Try another option.
Answer: 5 items, with indices interpreted against the appropriate pre- and post-update states
The final count is . Delete index paths identify the old state, while insert index paths identify the resulting state.
Question 51 of 60 · Implementing UICollectionView · Hard
A diffable data source snapshot contains two visually identical messages with the same database identifier. Applying it raises an exception. What is the correct model-level fix?
Not quite. Try another option.
Answer: Give every represented item a stable, unique identifier in the snapshot
Diffable data sources require unique item identifiers within a snapshot. Visual equality does not remove the identity requirement.
Question 52 of 60 · Implementing UICollectionView · Hard
A self-sizing collection-view cell uses Auto Layout, but its height stays at the estimated value even though multiline text needs more space. Which condition is essential inside the cell?
Not quite. Try another option.
Answer: Its content must have an unbroken vertical constraint chain from the content view's top to bottom
Self-sizing relies on constraints that determine the cell's complete size. A top-to-bottom chain allows Auto Layout to derive height from the multiline label.
Question 53 of 60 · UIToolbar · Hard
A toolbar contains flexible space between two leading actions and one trailing action. When the toolbar width changes, which item absorbs the extra horizontal space?
Not quite. Try another option.
Answer: A UIBarButtonItem created with the .flexibleSpace system item
Flexible-space items expand or contract to distribute unused toolbar width. Fixed-space items retain a specified width.
Question 54 of 60 · UIToolbar · Hard
A screen is inside a navigation controller whose built-in toolbar is used. The toolbar must show items specific to the visible child controller and update correctly during pushes and pops. Where should those items be configured?
Not quite. Try another option.
Answer: On each child controller through setToolbarItems(_:animated:)
A navigation controller manages its toolbar using the visible controller's toolbarItems. Configuring each child lets navigation transitions update the bar consistently.
Question 55 of 60 · UITabBar in applications · Hard
A UITabBarController has five child controllers. The user selects the fifth tab, which appears under the system-generated More interface. Which value should application logic use to identify the selected child reliably?
Not quite. Try another option.
Answer: selectedViewController, compared with the controller's stable application identity
selectedViewController identifies the actual selected child without relying on the More interface's presentation details or mutable tab ordering.
Question 56 of 60 · UITabBar in applications · Hard
Each tab contains its own navigation controller. After switching tabs, the app unexpectedly resets the previously selected tab to its root screen. Which architecture preserves independent navigation history?
Not quite. Try another option.
Answer: Create each tab's navigation controller once and retain it in the tab controller's viewControllers
Persistent per-tab navigation controllers retain their own stacks. Recreating or sharing a navigation controller discards or conflates navigation history.
Question 57 of 60 · UITabBar in applications · Hard
The current tab should remain selected when a user taps its tab bar item again, but the tab's navigation stack should pop to root. Which delegate decision is best suited to initiate this behavior?
Not quite. Try another option.
Answer: Detect reselection in tabBarController(_:shouldSelect:), pop the current stack, and return false
shouldSelect can detect that the candidate is already selected. The app can perform the custom pop and reject the redundant selection transition.
Question 58 of 60 · Database using SQLite · Hard
An SQLite table stores bank balances. A transfer performs one debit and one credit. The process must never commit only one of them, including when the credit violates a constraint. Which sequence provides the required atomicity?
Not quite. Try another option.
Answer: Begin a transaction, execute both updates, commit on success, and roll back on any failure
A transaction makes the updates atomic. If either statement fails, rollback prevents a partially applied transfer.
Question 59 of 60 · Database using SQLite · Hard
A prepared SQLite query uses WHERE nickname = ?. The application binds SQL NULL because the user has no nickname, but rows whose nickname is NULL are not returned. Why?
Not quite. Try another option.
Answer: Comparisons with NULL are unknown; the query must use IS NULL for that case
SQL NULL is not equal to any value, including another NULL. Null tests use IS NULL rather than = NULL.
Question 60 of 60 · Database using SQLite · Hard
Multiple background tasks share one SQLite connection opened with serialized threading support. Statements are protected by a serial queue, but a result row's text pointer is stored and read after sqlite3_step is called again. What is the defect?
Not quite. Try another option.
Answer: Column text pointers may become invalid after stepping or resetting, so the bytes must be copied before then
Memory returned by SQLite column-access APIs is owned by SQLite and has a limited lifetime. Convert or copy it before stepping, resetting, or finalizing the statement.
That's unit 5
Answer a few questions and your score shows up here.
Nearly through. Did unit 5 of INT372 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 5 of INT372 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.