示例工程 35-state-and-data-flow
35-state-and-data-flow/Sources/Ch35App/App.swift
import Ch35Kit
import SwiftUI
@main
struct Ch35App: App {
@State private var model = AppModel(count: 0)
var body: some Scene {
WindowGroup("状态与数据流") {
VStack(spacing: 16) {
StateCard()
CountEditor(model: model)
Text("App 级模型计数:\(model.count)")
.font(.footnote)
.foregroundStyle(.secondary)
}
.padding(24)
.frame(minWidth: 420, minHeight: 420)
.environment(model)
}
.windowResizability(.contentSize)
}
}