<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/FetchRequest",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI12FetchRequestV"
  },
  "title" : "FetchRequest"
}
-->

# FetchRequest

A property wrapper type that retrieves entities from a Core Data persistent
store.

```
@MainActor @propertyWrapper @preconcurrency struct FetchRequest<Result> where Result : NSFetchRequestResult
```

## Overview

Use a `FetchRequest` property wrapper to declare a [`FetchedResults`](/documentation/SwiftUI/FetchedResults)
property that provides a collection of Core Data managed objects to a
SwiftUI view. The request infers the entity type from the `Result`
placeholder type that you specify. Condition the request with an optional
predicate and sort descriptors. For example, you can create a request to
list all `Quake` managed objects that the
<doc://com.apple.documentation/documentation/SwiftUI/loading-and-displaying-a-large-data-feed>
sample code project defines to store earthquake data, sorted by their
`time` property:

```
@FetchRequest(sortDescriptors: [SortDescriptor(\.time, order: .reverse)])
private var quakes: FetchedResults<Quake> // Define Quake in your model.
```

Alternatively, when you need more flexibility, you can initialize the
request with a configured
<doc://com.apple.documentation/documentation/CoreData/NSFetchRequest>
instance:

```
@FetchRequest(fetchRequest: request)
private var quakes: FetchedResults<Quake>
```

Always declare properties that have a fetch request wrapper as private.
This lets the compiler help you avoid accidentally setting
the property from the memberwise initializer of the enclosing view.

The fetch request and its results use the managed object context stored
in the environment, which you can access using the
[`managedObjectContext`](/documentation/SwiftUI/EnvironmentValues/managedObjectContext) environment value. To
support user interface activity, you typically rely on the
<doc://com.apple.documentation/documentation/CoreData/NSPersistentContainer/viewContext>
property of a shared
<doc://com.apple.documentation/documentation/CoreData/NSPersistentContainer>
instance. For example, you can set a context on your top level content
view using a shared container that you define as part of your model:

```
ContentView()
    .environment(
        \.managedObjectContext,
        QuakesProvider.shared.container.viewContext)
```

When you need to dynamically change the predicate or sort descriptors,
access the request’s [`FetchRequest.Configuration`](/documentation/SwiftUI/FetchRequest/Configuration) structure.
To create a request that groups the fetched results according to a
characteristic that they share, use [`SectionedFetchRequest`](/documentation/SwiftUI/SectionedFetchRequest) instead.

## Topics

### Creating a fetch request

[`init ( sortDescriptors : predicate : animation :)`](/documentation/SwiftUI/FetchRequest/init(sortDescriptors:predicate:animation:))

Creates a fetch request based on a predicate and reference type sort
parameters.

[`init(entity:sortDescriptors:predicate:animation:)`](/documentation/SwiftUI/FetchRequest/init(entity:sortDescriptors:predicate:animation:))

Creates a fetch request for a specified entity description, based on a
predicate and sort parameters.

### Creating a fully configured fetch request

[`init(fetchRequest:animation:)`](/documentation/SwiftUI/FetchRequest/init(fetchRequest:animation:))

Creates a fully configured fetch request that uses the specified
animation when updating results.

[`init(fetchRequest:transaction:)`](/documentation/SwiftUI/FetchRequest/init(fetchRequest:transaction:))

Creates a fully configured fetch request that uses the specified
transaction when updating results.

### Configuring a request dynamically

[`Configuration`](/documentation/SwiftUI/FetchRequest/Configuration)

The request’s configurable properties.

[`projectedValue`](/documentation/SwiftUI/FetchRequest/projectedValue)

A binding to the request’s mutable configuration properties.

### Getting the fetched results

[`update()`](/documentation/SwiftUI/FetchRequest/update())

Updates the fetched results.

[`wrappedValue`](/documentation/SwiftUI/FetchRequest/wrappedValue)

The fetched results of the fetch request.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`Copyable`](/documentation/Swift/Copyable)

[`Escapable`](/documentation/Swift/Escapable)

[`DynamicProperty`](/documentation/SwiftUI/DynamicProperty)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)