Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
【One-Line Pitch】
A hands-on guide for iOS developers who want to master SwiftUI's declarative UI paradigm and Combine's reactive programming, building real apps from a calculator to a Pokémon viewer while learning state management and asynchronous data flow.
【Book Arc】
- **Opening (~0%–5%)**: Introduces SwiftUI as Apple's declarative replacement for imperative UIKit, contrasting "how to do" with "what to do." Starts building a calculator app UI using SwiftUI's DSL, covering View modifiers, Text styling, and layout basics.
- **Early (~5%–21%)**: Deepens the calculator project with layout refinements (Spacer, frame alignment), then shifts to state management. Explains @State, @Binding, and property wrappers for passing data through view hierarchies, plus a pure-function state machine for calculator logic and a history feature using .sheet.
- **Early (~21%–32%)**: Transitions to a larger Pokémon app example. Covers list creation with ScrollView, LazyVStack, and ForEach, building custom cells with nested stacks, SF Symbols, and expandable rows. Introduces ViewModels (PokemonViewModel, AbilityViewModel) and local JSON loading.
- **Middle (~32%–42%)**: Continues the Pokémon app with detail panels, blur effects, and a Settings model using ObservableObject and @Published. Then pivots to Combine fundamentals: Publisher, Subscriber, and Operator roles, with sink and assign as subscription methods bridging reactive and imperative worlds.
- **Middle (~42%–58%)**: Focuses on practical Combine usage in Playgrounds: common Publishers (Just, Future, PassthroughSubject), operators like reduce, scan, flatMap, zip, and timing controls (delay, debounce). Covers bridging async APIs with Future and Subject, and @Published's automatic Publisher generation.
- **Late (~58%–end)**: Explores subscription and binding patterns, including pitfalls like duplicate network requests from multiple assign calls. Discusses Redux-like architecture adapted for SwiftUI, using a Store with Actions and Reducers, while acknowledging SwiftUI's Binding as a complement to strict Redux flow.
【Key Takeaways】
- **Declarative UI with View modifiers** (Early): SwiftUI builds interfaces by describing results, not steps. Modifiers like .font, .padding, and .background wrap views to create new versions, enabling reusable components like CalculatorButton. Use predefined fonts for Dynamic Type support.
- **@State and @Binding for state flow** (Early): @State triggers UI refresh on value change but copies values across view layers, breaking updates. @Binding converts value semantics to reference semantics, letting deeply nested views (buttons in rows in pads) mutate the top-level model.
- **Property wrappers generalize getter/setter logic** (Early): Custom wrappers like @Converter encapsulate repeated transformations (currency conversion, UserDefaults access). They expose wrappedValue and projectedValue ($ prefix) for read/write and derived data.
- **ObservableObject and @Published drive SwiftUI models** (Early): Classes conforming to ObservableObject with @Published properties automatically notify views of changes. ViewModels like PokemonViewModel combine multiple data models to serve specific UI needs, keeping views simple.
- **Combine's three core roles** (Middle): Publisher emits events, Subscriber consumes them, and Operator transforms streams. sink bridges to closure-based imperative code, while assign binds values directly to object properties via key paths, enabling pure declarative updates.
- **Operators manage values and timing** (Middle): map and scan transform event values (e.g., reduce to a sum), while receive(on:), delay, and debounce handle scheduling and throttling. These are Publisher extensions returning new Publishers, central to Combine's composability.
- **Future and Subject bridge async code** (Middle): Future wraps single-result async tasks like network requests (success or error only). Subject (e.g., PassthroughSubject) handles multiple events—keyboard notifications, timers—by sending values into a subscribable stream.
- **Avoid duplicate subscriptions** (Late): Assigning one Publisher's output to multiple properties via separate assign calls can trigger multiple executions (e.g., two network requests). Share or restructure the pipeline to ensure single side effects.
【Reading Tips】
- **Skim the calculator UI chapters (0–16%)** if you're already comfortable with SwiftUI basics; focus instead on the state machine design and @Binding discussion, which are the conceptual core.
- **Deep-read the Combine chapters (37–58%)** with the provided Playground open. Run each example (reduce, flatMap, debounce) and modify inputs to internalize operator behavior—this is where the book's value peaks.
- **Treat the Pokémon app (21–37%) as a reference project**: skim cell layouts and Settings UI, but study how ViewModels are structured and how local JSON is loaded—patterns you'll reuse in real apps.
- **Watch for the Redux discussion near the end**: it's a condensed architecture lesson. If you're not building large apps, skim it; if you are, take notes on how Actions/Reducers adapt to SwiftUI's Binding model.
- **Don't skip the exercises** (marked with hints like "try using ZStack"): they force you to reimplement patterns (e.g., redrawing buttons, adding debounce to search) and solidify understanding better than re-reading.
【Coverage Limits】
Excerpts do not cover the book's final chapters on networking with URLSession, Swift Package Manager integration, or image downloading in detail—these are mentioned as upcoming topics but not fully demonstrated in the sampled material.
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
SwiftUI 和 Combine 编程 (王 巍)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share to WeChat Moments
SwiftUI 和 Combine 编程 (王 巍)(Z-Library)
Scan the QR code with WeChat to open this book
Tap the ··· menu in the top-right corner
Choose Share to Moments
You are already in WeChat. Tap ··· in the top-right corner and choose Share to Moments.
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
SwiftUI 和 Combine 编程 (王 巍)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment