Unit 2: MVVM Architecture - Practice Quiz

INT372 — Iphone Application Programming 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What does MVVM stand for?

Introduction to MVVM architecture Easy
A. Model-Visual-ViewManager
B. Module-View-VisualModel
C. Model-View-ViewController
D. Model-View-ViewModel

2 Which MVVM component stores and manages application data?

Introduction to MVVM architecture Easy
A. ViewModel
B. Model
C. Controller
D. View

3 What is the main role of the ViewModel in MVVM?

Introduction to MVVM architecture Easy
A. To display the Xcode toolbar
B. To connect data with the View
C. To install the iOS Simulator
D. To create application certificates

4 What is Xcode mainly used for?

Introduction to Xcode Easy
A. Creating database server clusters
B. Managing Android application packages
C. Developing Apple platform applications
D. Designing computer network cables

5 Which part of the Xcode workspace is primarily used to edit source code?

Workspace window Easy
A. Utility area
B. Debug area
C. Editor area
D. Navigator area

6 What is Interface Builder used for in Xcode?

Interface Builder Easy
A. Installing operating system updates
B. Creating source control accounts
C. Managing remote database servers
D. Designing user interfaces visually

7 What can be changed using the Attribute inspector?

Attribute inspector Easy
A. Properties of a selected UI element
B. The simulator's operating system
C. The computer's network connection
D. The application's signing certificate

8 What is the main purpose of the iOS Simulator?

Simulator and creating project Easy
A. To test an app on a simulated device
B. To design icons for an iOS app
C. To convert Swift code into Java code
D. To publish an app to the App Store

9 Which Xcode command is commonly used to begin creating a new application project?

Simulator and creating project Easy
A. Open Developer Documentation
B. Create a new Xcode project
C. Connect to a remote repository
D. Install additional components

10 What is a view controller mainly responsible for?

Looking at view controller Easy
A. Installing third-party frameworks
B. Managing a screen and its views
C. Managing the Mac file system
D. Publishing apps to the store

11 What is an IBOutlet used for?

Understanding outlets Easy
A. Opening the device camera directly
B. Connecting a UI element to code
C. Creating a new Swift package
D. Starting an application download

12 Which keyword commonly appears before an outlet declaration in UIKit?

Understanding outlets Easy
A. @available
B. @IBOutlet
C. @UIApplicationMain
D. @IBAction

13 What does an IBAction usually represent?

Actions Easy
A. A method triggered by a UI event
B. A tool for selecting simulators
C. A variable storing a UI element
D. A file containing application data

14 Which user interaction can commonly trigger an action connected to a UIButton?

Actions Easy
A. Renaming the project
B. Building the workspace
C. Tapping the button
D. Opening the navigator

15 Which UI element is normally used to display a short piece of text?

Designing UI Easy
A. UISlider
B. UISwitch
C. UILabel
D. UIButton

16 What is Auto Layout used for in an iOS interface?

Designing UI Easy
A. Compiling Swift source code
B. Downloading content from a server
C. Saving application data to files
D. Positioning UI elements with constraints

17 What is a common responsibility of the application delegate?

Application delegate Easy
A. Drawing every interface element
B. Responding to application-level events
C. Storing every user preference
D. Writing all ViewModel properties

18 Which navigator is used to browse project files in Xcode?

Working with navigator pane Easy
A. Report navigator
B. Issue navigator
C. Project navigator
D. Test navigator

19 What does the Utility pane commonly contain?

Utility pane Easy
A. Only compiler error messages
B. Only the application's source files
C. Simulator hardware controls
D. Inspectors and interface libraries

20 In which application state is an iOS app visible and receiving user input?

Activity life cycle Easy
A. Active
B. Background
C. Inactive
D. Suspended

21 A view controller currently downloads user data, formats it, and updates labels. Under MVVM, where should the formatting logic primarily be moved?

Introduction to MVVM architecture Medium
A. The AppDelegate
B. The Model
C. The ViewModel
D. The storyboard scene that contains the labels and layout constraints

22 A ViewModel exposes an isLoginEnabled property based on whether two text fields contain valid values. What is the main architectural benefit?

Introduction to MVVM architecture Medium
A. Validation can be tested without creating the view
B. The application delegate owns all login state and updates every controller
C. The Model can directly modify the button
D. The storyboard automatically validates both fields

23 An iOS project compiles successfully but crashes while running. Which Xcode feature is most appropriate for pausing execution at the suspected line and inspecting variables?

Introduction to Xcode Medium
A. A project navigator group containing the affected source files
B. A constraint in Interface Builder
C. A breakpoint in the source editor
D. A scheme archive action

24 While debugging a layout issue, a developer wants more horizontal space for the source editor without closing the project. Which workspace adjustment is most suitable?

Workspace window Medium
A. Delete unused project file groups
B. Hide the navigator and inspector areas
C. Change the active build configuration
D. Open the storyboard through the application delegate and rebuild the scheme

25 A label is correctly positioned on one iPhone size but shifts incorrectly on another. What should the developer modify in Interface Builder?

Interface Builder Medium
A. The ViewModel access level
B. The application bundle identifier
C. The complete simulator runtime configuration for every supported device
D. The Auto Layout constraints

26 A developer needs to change a button's displayed title and text color without writing code. Which Xcode area should be used?

Attribute inspector Medium
A. The Attribute inspector
B. The Debug navigator
C. The File inspector, after changing the target membership and localization settings
D. The Report navigator

27 A newly created application must be checked on two simulated iPhone screen sizes. What is the most efficient approach?

Simulator and creating project Medium
A. Duplicate every view controller and configure one copy for each simulated screen size
B. Create a separate Xcode project for each device
C. Change the bundle identifier before each run
D. Run the same scheme on two simulator devices

28 An application needs camera behavior that the selected Simulator runtime cannot reproduce accurately. What should the developer do?

Simulator and creating project Medium
A. Move camera code into the application delegate
B. Test that behavior on a physical device
C. Create another simulator-only target with a different bundle identifier and signing certificate
D. Add a camera constraint in the storyboard

29 A view controller must configure a label after all storyboard outlets have been connected. Which method is the appropriate place for this initial setup?

Looking at view controller Medium
A. loadView()
B. viewDidLoad()
C. application(_:didFinishLaunchingWithOptions:) in the application delegate
D. viewWillDisappear(_:)

30 A screen refreshes account data every time it becomes visible after another screen is dismissed. Which view controller method best fits this requirement?

Looking at view controller Medium
A. viewWillAppear(_:)
B. didReceiveMemoryWarning(), because it is called before a previously hidden screen is displayed again
C. viewDidLoad()
D. viewWillDisappear(_:)

31 An IBOutlet is declared as weak, but the connected label remains visible and usable after loading. What retains the label?

Understanding outlets Medium
A. The application delegate through the active storyboard and navigation stack
B. The outlet declaration
C. Its superview
D. The ViewModel

32 A storyboard label was connected to titleLabel, but the property was later deleted from the view controller. What is the likely runtime result if the stale connection remains?

Understanding outlets Medium
A. The storyboard reconnects the label to the nearest property with a compatible UIKit type
B. A silent replacement outlet is generated
C. A compile-time Auto Layout warning
D. A key-value coding connection exception

33 Several buttons should call the same IBAction, while the method must identify which button triggered it. Which method signature is most useful?

Actions Medium
A. @IBOutlet weak var choose: UIButton!, followed by a separate action stored in the application delegate
B. func choose(_ sender: UIViewController)
C. @IBAction func choose()
D. @IBAction func choose(_ sender: UIButton)

34 A button's action is connected to the Touch Down event instead of Touch Up Inside. What behavioral difference should be expected?

Actions Medium
A. The action waits until the application enters the background and the current scene resigns active
B. The action fires when the finger first presses
C. The action fires only after the finger leaves
D. The action fires when the view controller loads

35 Three buttons should remain equal in width and evenly spaced as the device rotates. Which Interface Builder approach is most appropriate?

Designing UI Medium
A. Assign each button a fixed screen coordinate
B. Update their frames only in viewDidLoad()
C. Create three separate view controllers and embed one button in each controller's root view
D. Place them in a horizontal stack view

36 Which task is most appropriately performed in application(_:didFinishLaunchingWithOptions:)?

Application delegate Medium
A. Update a label whenever its screen appears
B. Initialize an application-wide service
C. Handle every button tap in the application
D. Apply individual Auto Layout constraints to each storyboard scene after every device rotation

37 A build fails because a symbol is undefined, and the developer wants to jump directly through the listed compiler errors. Which navigator should be opened?

Working with navigator pane Medium
A. The Symbol navigator
B. The Breakpoint navigator
C. The Issue navigator
D. The Project navigator with every group expanded and all generated build products displayed

38 A source file compiles in the project but is missing from one application target. Which inspector setting should be checked in the utility pane?

Utility pane Medium
A. Target Membership
B. Module Stability
C. Content Mode
D. The complete list of simulator devices installed for all Xcode toolchains

39 An application pauses an active timer when it is interrupted by an incoming call. In a traditional app-delegate lifecycle, which callback is most appropriate?

Activity life cycle Medium
A. application(_:didFinishLaunchingWithOptions:), because interruptions restart the application lifecycle
B. applicationDidBecomeActive(_:)
C. applicationWillResignActive(_:)
D. applicationWillEnterForeground(_:)

40 A scene-based application should refresh sensitive information whenever its scene returns from the background and becomes interactive. Which callback best matches that moment?

Activity life cycle Medium
A. applicationWillTerminate(_:), followed by reloading the storyboard and reconstructing every visible controller
B. sceneDidEnterBackground(_:)
C. sceneDidBecomeActive(_:)
D. sceneWillResignActive(_:)

41 A view controller owns a view model, and the view model exposes a closure that the controller assigns to update its UI. Instruments shows that the controller is never deallocated after dismissal. Which change best preserves MVVM communication while fixing the likely leak?

Introduction to MVVM architecture Hard
A. Move the closure into the model and retain the controller through a protocol property
B. Declare every view-model property weak and recreate the model after each update
C. Capture the controller weakly in the closure and unwrap it before updating the UI
D. Make the controller a singleton so the retained instance is reused across presentations

42 A view model fetches data on a background queue and publishes a formatted string that is immediately assigned to a label by the view controller. Which design most correctly handles thread safety and MVVM separation?

Introduction to MVVM architecture Hard
A. Store the label in the view model and dispatch its property changes to the main thread
B. Format in the view controller and update the label directly from the background queue
C. Return the network response unchanged and let the label parse it on the main thread
D. Format in the view model and deliver the observable UI state on the main thread

43 An Xcode workspace contains an application project and a separate dynamic framework project. Both build independently, but the application reports that the framework module cannot be loaded at runtime. Which configuration is most appropriate?

Introduction to Xcode Hard
A. Add the framework product to the app's frameworks section using Embed & Sign
B. Add the framework's source directory only to the app's header search paths
C. Copy the framework project file into the application's compiled resources phase
D. Select the framework scheme whenever the application is launched from Xcode

44 Which mapping of Xcode workspace-window components to responsibilities is correct?

Workspace window Hard
A. Scheme selector—breakpoint scope; jump bar—simulator selection; debug area—asset management
B. Scheme selector—run destination; jump bar—code navigation; debug area—variables and console
C. Scheme selector—file history; jump bar—target signing; debug area—storyboard constraints
D. Scheme selector—source control branch; jump bar—build settings; debug area—target membership

45 A view with width points contains a subview with required leading and trailing constraints of points and a required width constraint of points. The design must preserve both margins on different screen widths. Which Interface Builder change is most appropriate?

Interface Builder Hard
A. Add a required center constraint while retaining all three existing required constraints
B. Raise content-hugging priority so the intrinsic size overrides both required margins
C. Lower the width constraint priority below required so the margins determine the width
D. Lower the leading constraint priority so the fixed width determines the horizontal position

46 A developer must set a button's title for its Disabled state, assign an accessibility identifier, and change the storyboard file's target membership. Which inspector sequence should be used?

Attribute inspector Hard
A. Identity inspector, Attributes inspector, Connections inspector
B. Attributes inspector, Identity inspector, File inspector
C. Attributes inspector, Size inspector, Quick Help inspector
D. Size inspector, Connections inspector, File inspector

47 An image named ProfileIcon.png loads in the Simulator, but returns nil on a physical device when requested as profileicon.png. Assuming the asset is copied correctly, what is the most likely cause?

Simulator and creating project Hard
A. The simulator's host file system tolerates a filename case mismatch that the device does not
B. The device automatically converts PNG filenames into lowercase names during installation
C. The simulator loads missing images from Xcode's global derived-data image cache
D. The physical device requires all PNG resources to be registered as launch-screen assets

48 In a scene-based iOS project, a developer removes the main storyboard reference from the target settings and creates the window programmatically, but launch still fails while trying to load that storyboard. What was most likely overlooked?

Simulator and creating project Hard
A. The storyboard name remains in the scene configuration within the application manifest
B. The simulator cached the storyboard because derived data contains compiled Swift modules
C. The storyboard is still selected as the active file in the project navigator
D. The root view controller must be created exclusively in the application delegate initializer

49 A parent view controller programmatically embeds a child controller. Which sequence correctly establishes containment before the child begins normal appearance handling?

Looking at view controller Hard
A. Add and constrain its view, call viewDidAppear, then call addChild
B. Call addChild, add and constrain its view, then call didMove(toParent:)
C. Call didMove(toParent:), add its view, then call addChild
D. Present the child modally, add its view, then dismiss the presentation

50 A XIB contains a helper object as a top-level object. It is connected to a weak outlet but is not inserted into any retained view hierarchy. The outlet becomes nil after loading. What is the best correction?

Understanding outlets Hard
A. Make the outlet strong so the owner retains the top-level helper object
B. Declare the outlet computed so the XIB reconstructs the object on every access
C. Convert the outlet into an action so Interface Builder retains its target
D. Keep the outlet weak and add the helper object to the controller's view hierarchy

51 A view model receives data before its view controller's view has loaded. A property observer immediately assigns the data to an implicitly unwrapped label outlet, causing a crash. Which solution best handles this edge case?

Understanding outlets Hard
A. Force access to every outlet in the controller initializer before assigning the view model
B. Move the label into the view model so it exists before storyboard unarchiving begins
C. Convert the label outlet to a class property shared by every controller instance
D. Store the state and render it in viewDidLoad, updating immediately only when isViewLoaded is true

52 Four buttons are connected to one IBAction, and their visible titles are localized. The controller must reliably determine which command was requested. Which approach is most robust?

Actions Hard
A. Inspect the current touch coordinates and infer which localized command was tapped
B. Compare the sender with known outlets or map each control to a command identifier
C. Compare the sender's displayed title with hard-coded English command strings
D. Use the sender's position because Auto Layout preserves a fixed visual order

53 A reusable table-view cell calls addTarget(_:action:for:) on its button every time configure runs. After several reuse cycles, one tap invokes the same action multiple times. What is the safest design correction?

Actions Hard
A. Disable user interaction during reuse and re-enable it after each configuration call
B. Create a new button in every configuration call and leave the old button attached
C. Register the invariant target-action once during cell initialization rather than during configuration
D. Remove every target in prepareForReuse, including targets installed by other components

54 A multiline label supports Dynamic Type but clips text at accessibility sizes. It has required top and bottom constraints, numberOfLines = 0, and a required fixed-height constraint. Which redesign best preserves accessibility?

Designing UI Hard
A. Change the label to one line and enable truncation at the tail for all size categories
B. Remove the fixed height and let intrinsic content size determine the label's vertical size
C. Keep the fixed height and reduce the font whenever the preferred size category increases
D. Remove the bottom constraint and position the label using an absolute frame origin

55 An interface must switch from a vertical control arrangement in compact width to a horizontal arrangement in regular width, including Split View resizing on iPad. Which design is most reliable?

Designing UI Hard
A. Use trait-aware constraints or stack-view axis changes based on the current size class
B. Select the arrangement once by comparing the device model with a stored phone list
C. Create separate controllers and choose one exclusively from the operating-system version
D. Select the arrangement only from the launch screen's initial pixel dimensions

56 A background URLSession finishes transfers while the application is suspended. iOS relaunches the app and provides a completion handler to the application delegate. When should that handler be called?

Application delegate Hard
A. Only when the application next becomes active and displays its root controller
B. After the session delegate reports that all background events have finished processing
C. Immediately inside didFinishLaunchingWithOptions before restoring session delegates
D. When the first download task reports progress greater than zero after relaunch

57 A test passed locally yesterday but failed in an earlier CI-style Xcode run. The developer needs the complete logs and results from that historical test invocation. Which navigator is most appropriate?

Working with navigator pane Hard
A. Report navigator
B. Symbol navigator
C. Breakpoint navigator
D. Issue navigator

58 A developer selects a storyboard constraint and wants to edit its constant and priority, then selects a Swift file and wants to change its target membership. Which utility-pane inspectors are required in order?

Utility pane Hard
A. File inspector, then Attributes inspector
B. Size inspector, then File inspector
C. Connections inspector, then Quick Help inspector
D. Attributes inspector, then Identity inspector

59 A scene-based application is active when the user presses the Home button. Ignoring unusual interruptions, which scene-level callback order should the application expect?

Activity life cycle Hard
A. sceneDidEnterBackground(_:) followed by sceneWillResignActive(_:)
B. sceneWillEnterForeground(_:) followed by sceneWillResignActive(_:)
C. sceneWillResignActive(_:) followed by sceneDidEnterBackground(_:)
D. sceneDidDisconnect(_:) followed by sceneDidBecomeActive(_:)

60 An application saves critical user edits only in applicationWillTerminate(_:). Some edits are lost after the system removes the suspended app from memory. Which strategy is correct?

Activity life cycle Hard
A. Persist important state as it changes and finalize it when the scene enters the background
B. Save only in sceneDidBecomeActive(_:) because background transitions cannot perform file writes
C. Store edits solely in view-controller properties because suspended memory is permanently preserved
D. Keep using termination because iOS always invokes it before reclaiming suspended applications