Discussion 議論
SwiftUI returns the value associated with this property when you use Fetch
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:
(fetchRequest: request)
private var quakes: FetchedResults<Quake>
You access the request’s wrapped
, which contains a Fetched
instance, by referring to the quakes
property by name:
Text("Found \(quakes.count) 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<Quake>(fetchRequest: request)
var quakes: FetchedResults<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.