Discussion 議論
This property behaves like the wrapped
of a Fetch
. In particular, SwiftUI returns the value associated with this property when you use Sectioned
as a property wrapper and then access the wrapped property by name. For example, consider the following quakes
property declaration that fetches a Quake
type that the Loading and Displaying a Large Data Feed sample code project defines:
<String, Quake>(
sectionIdentifier: \.day,
sortDescriptors: [SortDescriptor(\.time, order: .reverse)]
)
private var quakes: SectionedFetchResults<String, Quake>
You access the request’s wrapped
, which contains a Sectioned
instance, by referring to the quakes
property by name. That value is a collection of sections, each of which contains a group of managed objects:
Text("Found \(quakes.count) days of earthquakes")
If you need to separate the request and the result entities, you can declare quakes
in two steps by using the request’s wrapped
to obtain the results:
var fetchRequest = FetchRequest<String, Quake>(
fetchRequest: request,
sectionIdentifier: \.day)
var quakes: FetchedResults<String, Quake> { fetchRequest.wrappedValue }
The wrapped
property returns an empty array when there are no fetched results; for example, because no entities satisfy the predicate, or because the data store is empty.