CSE 335 STUDY GUIDE QUESTIONS WITH
ANSWERS AND EXPLANATIONS
1. Study this case as a concept check: Two controls in an HStack should be pushed to opposite
sides. Which
technique or principle applies most directly?
A. Divider
B. Spacer
C. AnyView
D. Group
Correct Answer: B. Spacer
Explanation: Spacer expands to consume available layout space and can push neighboring views
apart.
2. Which concept should guide the implementation of this requirement? A request body should be
encoded from a
Swift value into JSON.
A. NSLock
B. NotificationCenter
C. Codable
D. GeometryReader
Correct Answer: C. Codable
Explanation: Codable supports structured encoding/decoding between Swift models and formats
such as JSON when representations
match.
3. Identify the most suitable design decision for this situation: A cart total is shown in multiple
screens and must
update from one authoritative model.
A. Recompute the value from unrelated global variables
B. Store a second editable copy in every child view
C. A single source of truth
D. Copy the same mutable value into several independent @State properties
Correct Answer: C. A single source of truth
Explanation: SwiftUI data flow is most reliable when one owner holds mutable state and
dependent views derive or bind to it.
4. A study guide asks you to connect a requirement with the correct mobile-development idea.
Requirement: A
server-backed list refreshes and rows may move to new positions. Which choice is the strongest
match?
A. Regenerate every row ID on each refresh
B. Use stable IDs for editable list rows
C. Identify rows only by a nonunique title
D. Use the current array offset as permanent identity
Correct Answer: B. Use stable IDs for editable list rows
Explanation: Stable identities allow edits, deletes, and moves to target the intended model item
as collection order changes.
,5. A study guide asks you to connect a requirement with the correct mobile-development idea.
Requirement: A
failed save needs a brief message with an OK action. Which choice is the strongest match?
A. ScrollView
B. NavigationLink
C. .sheet
D. .alert
Correct Answer: D. .alert
Explanation: Alerts are suited to short, interruptive messages or confirmations requiring
immediate acknowledgment or choice.
6. Study this case as a concept check: A repository performs two asynchronous service calls
sequentially. Which
technique or principle applies most directly?
A. async/await
B. Spin in a while loop until the response arrives
C. Busy-wait on the main thread
D. Block with a long synchronous sleep
Correct Answer: A. async/await
Explanation: async/await expresses asynchronous work without blocking the caller thread while
waiting for completion.
7. Study this case as a concept check: An event screen needs a start date and time field. Which
technique or
principle applies most directly?
A. Gauge
B. ColorPicker
C. DatePicker
D. Stepper
Correct Answer: C. DatePicker
Explanation: DatePicker is the standard SwiftUI control for selecting dates and times.
8. A study guide asks you to connect a requirement with the correct mobile-development idea.
Requirement:
Decoded results need to be published to a SwiftUI screen. Which choice is the strongest match?
A. Disable concurrency entirely
B. Store every UI value in UserDefaults
C. Mutate UI state from an arbitrary background context
D. Update UI-observed state on the main actor
Correct Answer: D. Update UI-observed state on the main actor
Explanation: UI-facing state should be mutated on the main actor to preserve thread-safety
expectations of the UI framework.
9. Identify the most suitable design decision for this situation: A settings page contains grouped
switches and
selection controls.
A. Canvas
B. TimelineView
C. LazyHGrid
D. Form
Correct Answer: D. Form
Explanation: Form groups standard data-entry controls in a platform-appropriate
settings/data-entry presentation.
, 10. Identify the most suitable design decision for this situation: A detail screen disappears while
its large image
download is still running.
A. Cancel obsolete tasks
B. Restart the entire application
C. Let every stale request finish and overwrite newer results
D. Block the main thread until all requests finish
Correct Answer: A. Cancel obsolete tasks
Explanation: Cancellation prevents outdated asynchronous work from wasting resources or
racing newer requests.
11. Identify the most suitable design decision for this situation: A small immutable settings value
should be copied
without shared reference identity.
A. A struct
B. A global singleton
C. A class only
D. A protocol extension only
Correct Answer: A. A struct
Explanation: Structs have value semantics and are commonly suitable for lightweight model
values in Swift.
12. Study this case as a concept check: A search service exposes page tokens for long result sets.
Which
technique or principle applies most directly?
A. Create a new app target per page
B. Download an unbounded dataset in one response
C. Store page numbers in Keychain only
D. Pagination / incremental loading
Correct Answer: D. Pagination / incremental loading
Explanation: Pagination limits transfer and rendering cost for large remote collections.
13. Study this case as a concept check: A screen mode can be list, grid, or map. Which technique
or principle
applies most directly?
A. A duplicated Boolean pair
B. A raw unstructured string everywhere
C. An enum
D. A floating-point value
Correct Answer: C. An enum
Explanation: Enums model a finite set of related states and can attach associated data when
needed.
14. A study guide asks you to connect a requirement with the correct mobile-development idea.
Requirement: A
reference-data endpoint changes rarely and can be reused for a period. Which choice is the
strongest match?
A. Cache forever with no expiry or versioning
B. Store all response bytes in a UI label
C. Cache reusable responses with a clear invalidation policy
D. Always redownload immutable resources on every redraw
Correct Answer: C. Cache reusable responses with a clear invalidation policy
Explanation: Caching can reduce latency and network use, but cached data needs defined
freshness/invalidation behavior.
ANSWERS AND EXPLANATIONS
1. Study this case as a concept check: Two controls in an HStack should be pushed to opposite
sides. Which
technique or principle applies most directly?
A. Divider
B. Spacer
C. AnyView
D. Group
Correct Answer: B. Spacer
Explanation: Spacer expands to consume available layout space and can push neighboring views
apart.
2. Which concept should guide the implementation of this requirement? A request body should be
encoded from a
Swift value into JSON.
A. NSLock
B. NotificationCenter
C. Codable
D. GeometryReader
Correct Answer: C. Codable
Explanation: Codable supports structured encoding/decoding between Swift models and formats
such as JSON when representations
match.
3. Identify the most suitable design decision for this situation: A cart total is shown in multiple
screens and must
update from one authoritative model.
A. Recompute the value from unrelated global variables
B. Store a second editable copy in every child view
C. A single source of truth
D. Copy the same mutable value into several independent @State properties
Correct Answer: C. A single source of truth
Explanation: SwiftUI data flow is most reliable when one owner holds mutable state and
dependent views derive or bind to it.
4. A study guide asks you to connect a requirement with the correct mobile-development idea.
Requirement: A
server-backed list refreshes and rows may move to new positions. Which choice is the strongest
match?
A. Regenerate every row ID on each refresh
B. Use stable IDs for editable list rows
C. Identify rows only by a nonunique title
D. Use the current array offset as permanent identity
Correct Answer: B. Use stable IDs for editable list rows
Explanation: Stable identities allow edits, deletes, and moves to target the intended model item
as collection order changes.
,5. A study guide asks you to connect a requirement with the correct mobile-development idea.
Requirement: A
failed save needs a brief message with an OK action. Which choice is the strongest match?
A. ScrollView
B. NavigationLink
C. .sheet
D. .alert
Correct Answer: D. .alert
Explanation: Alerts are suited to short, interruptive messages or confirmations requiring
immediate acknowledgment or choice.
6. Study this case as a concept check: A repository performs two asynchronous service calls
sequentially. Which
technique or principle applies most directly?
A. async/await
B. Spin in a while loop until the response arrives
C. Busy-wait on the main thread
D. Block with a long synchronous sleep
Correct Answer: A. async/await
Explanation: async/await expresses asynchronous work without blocking the caller thread while
waiting for completion.
7. Study this case as a concept check: An event screen needs a start date and time field. Which
technique or
principle applies most directly?
A. Gauge
B. ColorPicker
C. DatePicker
D. Stepper
Correct Answer: C. DatePicker
Explanation: DatePicker is the standard SwiftUI control for selecting dates and times.
8. A study guide asks you to connect a requirement with the correct mobile-development idea.
Requirement:
Decoded results need to be published to a SwiftUI screen. Which choice is the strongest match?
A. Disable concurrency entirely
B. Store every UI value in UserDefaults
C. Mutate UI state from an arbitrary background context
D. Update UI-observed state on the main actor
Correct Answer: D. Update UI-observed state on the main actor
Explanation: UI-facing state should be mutated on the main actor to preserve thread-safety
expectations of the UI framework.
9. Identify the most suitable design decision for this situation: A settings page contains grouped
switches and
selection controls.
A. Canvas
B. TimelineView
C. LazyHGrid
D. Form
Correct Answer: D. Form
Explanation: Form groups standard data-entry controls in a platform-appropriate
settings/data-entry presentation.
, 10. Identify the most suitable design decision for this situation: A detail screen disappears while
its large image
download is still running.
A. Cancel obsolete tasks
B. Restart the entire application
C. Let every stale request finish and overwrite newer results
D. Block the main thread until all requests finish
Correct Answer: A. Cancel obsolete tasks
Explanation: Cancellation prevents outdated asynchronous work from wasting resources or
racing newer requests.
11. Identify the most suitable design decision for this situation: A small immutable settings value
should be copied
without shared reference identity.
A. A struct
B. A global singleton
C. A class only
D. A protocol extension only
Correct Answer: A. A struct
Explanation: Structs have value semantics and are commonly suitable for lightweight model
values in Swift.
12. Study this case as a concept check: A search service exposes page tokens for long result sets.
Which
technique or principle applies most directly?
A. Create a new app target per page
B. Download an unbounded dataset in one response
C. Store page numbers in Keychain only
D. Pagination / incremental loading
Correct Answer: D. Pagination / incremental loading
Explanation: Pagination limits transfer and rendering cost for large remote collections.
13. Study this case as a concept check: A screen mode can be list, grid, or map. Which technique
or principle
applies most directly?
A. A duplicated Boolean pair
B. A raw unstructured string everywhere
C. An enum
D. A floating-point value
Correct Answer: C. An enum
Explanation: Enums model a finite set of related states and can attach associated data when
needed.
14. A study guide asks you to connect a requirement with the correct mobile-development idea.
Requirement: A
reference-data endpoint changes rarely and can be reused for a period. Which choice is the
strongest match?
A. Cache forever with no expiry or versioning
B. Store all response bytes in a UI label
C. Cache reusable responses with a clear invalidation policy
D. Always redownload immutable resources on every redraw
Correct Answer: C. Cache reusable responses with a clear invalidation policy
Explanation: Caching can reduce latency and network use, but cached data needs defined
freshness/invalidation behavior.