struct Configuration
Discussion 議論
SwiftUI returns the value associated with this property when you use Fetch
as a property wrapper on a Fetched
instance, and then access the results with a dollar sign ($
) prefix. The value that SwiftUI returns is a Binding
to the request’s Fetch
structure, which dynamically configures the request.
For example, consider the following fetch request for a type that the Loading and Displaying a Large Data Feed sample code project defines to store earthquake data, sorted based on the time
property:
SortDescriptor(\.time, order: .reverse)]) (sortDescriptors: [
private var quakes: FetchedResults<Quake>
You can use the projected value to enable a Table
instance to make updates:
Table(quakes, sortOrder: $quakes.sortDescriptors) {
TableColumn("Place", value: \.place)
TableColumn("Time", value: \.time) { quake in
Text(quake.time, style: .time)
}
}
Because you initialize the table using a binding to the descriptors, the table can modify the sort in response to actions that the user takes, like clicking a column header.