← 返回 snapchat 的题目列表iOS Scrollable Grid & Swift Concurrency
类型:qbank
Build an iOS scrollable square grid, then answer Swift and GCD questions about value types, copy-on-write, memory, weak references, and dispatch ordering.
Requirements
For the iOS coding round, build a local app component in SwiftUI or UIKit:
Render a scrollable square grid with fixed rows and columns.
Change a cell's color when tapped.
Make row and column counts externally configurable.
Change each tapped cell to a random color.
Navigate to a detail page showing the selected color.
Allow color edits on the detail page to propagate back to the grid.
Domain-specific Swift questions may include:
Predicting output order for DispatchQueue.async and sync snippets.
class vs struct and value semantics.
Copy-on-write implementation.
Stack vs heap.
weak vs unowned and why unowned can crash.
Implementing a dictionary without using the system dictionary as the backing store.
Notes
For SwiftUI, a clean implementation uses LazyVGrid, stable cell IDs, @State or observable state for cell colors, and a binding or callback to propagate detail edits. For UIKit, use UICollectionView with a diffable or simple data source.
For GCD questions, reason about the current queue, whether sync blocks the caller, and whether queued async work has executed yet. For value-type questions, emphasize copy-on-write storage sharing until mutation.
Preparation
Build the grid in both SwiftUI and UIKit if you have time; at least know one path cold.
Practice two GCD output-order snippets and narrate the queue state line by line.
Implement a tiny hash table with buckets, collision handling, resize, get, put, and remove.
Prepare concise explanations for ARC, weak, unowned, and retain cycles.