<!--
{
  "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/init(fetchRequest:animation:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI12FetchRequestV05fetchD09animationACyxGSo07NSFetchD0CyxG_AA9AnimationVSgtcfc"
  },
  "title" : "init(fetchRequest:animation:)"
}
-->

# init(fetchRequest:animation:)

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

```
@MainActor @preconcurrency init(fetchRequest: NSFetchRequest<Result>, animation: Animation? = nil)
```

## Parameters

`fetchRequest`

An
<doc://com.apple.documentation/documentation/CoreData/NSFetchRequest>
instance that describes the search criteria for retrieving data
from the persistent store.

`animation`

The animation to use for user interface changes that
result from changes to the fetched results.

## Discussion

Use this initializer when you want to configure a fetch
request with more than a predicate and sort descriptors.
For example, you can vend a request from a `Quake` managed object
that the
<doc://com.apple.documentation/documentation/SwiftUI/loading-and-displaying-a-large-data-feed>
sample code project defines to store earthquake data.
Limit the number of results to `1000` by setting a
<doc://com.apple.documentation/documentation/CoreData/NSFetchRequest/fetchLimit>
for the request:

```
extension Quake {
    var request: NSFetchRequest<Quake> {
        let request = NSFetchRequest<Quake>(entityName: "Quake")
        request.sortDescriptors = [
            NSSortDescriptor(
                keyPath: \Quake.time,
                ascending: true)]
        request.fetchLimit = 1000
        return request
    }
}
```

Use the request to define a [`FetchedResults`](/documentation/SwiftUI/FetchedResults) property:

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

If you only need to configure the request’s predicate and sort
descriptors, use [`init(sortDescriptors:predicate:animation:)`](/documentation/SwiftUI/FetchRequest/init(sortDescriptors:predicate:animation:))
instead. If you need to specify a [`Transaction`](/documentation/SwiftUI/Transaction) rather than an
optional [`Animation`](/documentation/SwiftUI/Animation), use [`init(fetchRequest:transaction:)`](/documentation/SwiftUI/FetchRequest/init(fetchRequest:transaction:)).

---

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)