<!--
{
  "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/FetchedResults",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI14FetchedResultsV"
  },
  "title" : "FetchedResults"
}
-->

# FetchedResults

A collection of results retrieved from a Core Data store.

```
@MainActor @preconcurrency struct FetchedResults<Result> where Result : NSFetchRequestResult
```

## Overview

Use a `FetchedResults` instance to show or edit Core Data managed objects in
your app’s user interface. You request a particular set of results by
specifying a `Result` type as the entity type, and annotating the fetched
results property declaration with a [`FetchRequest`](/documentation/SwiftUI/FetchRequest) property wrapper.
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>
```

The results instance conforms to
<doc://com.apple.documentation/documentation/Swift/RandomAccessCollection>,
so you access it like any other collection. For example, you can create
a [`List`](/documentation/SwiftUI/List) that iterates over all the results:

```
List(quakes) { quake in
    NavigationLink(destination: QuakeDetail(quake: quake)) {
        QuakeRow(quake: quake)
    }
}
```

When you need to dynamically change the request’s predicate or sort
descriptors, set the result instance’s [`nsPredicate`](/documentation/SwiftUI/FetchedResults/nsPredicate) and
[`sortDescriptors`](/documentation/SwiftUI/FetchedResults/sortDescriptors) or [`nsSortDescriptors`](/documentation/SwiftUI/FetchedResults/nsSortDescriptors) properties, respectively.

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 container that you define as part of your model:

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

## Topics

### Configuring the associated fetch request

[`nsPredicate`](/documentation/SwiftUI/FetchedResults/nsPredicate)

The request’s predicate.

[`sortDescriptors`](/documentation/SwiftUI/FetchedResults/sortDescriptors)

The request’s sort descriptors, accessed as value types.

[`nsSortDescriptors`](/documentation/SwiftUI/FetchedResults/nsSortDescriptors)

The request’s sort descriptors, accessed as reference types.

### Getting indices

[`startIndex`](/documentation/SwiftUI/FetchedResults/startIndex)

The index of the first entity in the results collection.

[`endIndex`](/documentation/SwiftUI/FetchedResults/endIndex)

The index that’s one greater than the last valid subscript argument.

### Getting results

[`subscript(_:)`](/documentation/SwiftUI/FetchedResults/subscript(_:))

Gets the entity at the specified index.

## Relationships

### Conforms To

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

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

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

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

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

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

---

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)