<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PhotoKit",
  "identifier" : "/documentation/Photos/PHFetchResultChangeDetails",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Photos"
    ],
    "preciseIdentifier" : "c:objc(cs)PHFetchResultChangeDetails"
  },
  "title" : "PHFetchResultChangeDetails"
}
-->

# PHFetchResultChangeDetails

A description of changes that occurred in the set of asset or collection objects listed in a fetch result.

```
class PHFetchResultChangeDetails<ObjectType> where ObjectType : PHObject
```

## Overview

A [`PHFetchResultChangeDetails`](/documentation/Photos/PHFetchResultChangeDetails) object provides detailed information about the differences between two fetch results—one that you previously obtained and an updated one that would result if you performed the same fetch again. The change details object provides information useful for updating a UI that lists the contents of a fetch result, such as the indexes of added, removed, and rearranged objects.

### Processing Changes in Order

PhotoKit describes [`changedIndexes`](/documentation/Photos/PHFetchResultChangeDetails/changedIndexes) in the *after* state, while <doc://com.apple.documentation/documentation/UIKit/UICollectionView>w’s <doc://com.apple.documentation/documentation/UIKit/UICollectionView/performBatchUpdates(_:completion:)> expects them in the *before* state. As a result, [`changedIndexes`](/documentation/Photos/PHFetchResultChangeDetails/changedIndexes) can’t be used safely inside <doc://com.apple.documentation/documentation/UIKit/UICollectionView/performBatchUpdates(_:completion:)>.

Instead, use [`changedIndexes`](/documentation/Photos/PHFetchResultChangeDetails/changedIndexes) *after* and outside the <doc://com.apple.documentation/documentation/UIKit/UICollectionView/performBatchUpdates(_:completion:)> call, reapplying the code used to configure cells in <doc://com.apple.documentation/documentation/UIKit/UICollectionView/cellForItem(at:)> rather than telling <doc://com.apple.documentation/documentation/UIKit/UICollectionView> to reload.

```swift
let collectionView = UICollectionView()
let fetchResultChangeDetails = PHFetchResultChangeDetails()
let deletedCollectionIndicesBeforeChanges = IndexSet()
let insertedCollectionIndicesAfterDeletions = IndexSet()
let deletedPhotoPathsBeforeChanges: [IndexPath] = []
let insertedPhotoPathsAfterDeletions: [IndexPath] = []

collectionView.performBatchUpdates({ () -> Void in
    if (!deletedCollectionIndicesBeforeChanges.isEmpty) {
        collectionView.deleteSections(deletedCollectionIndicesBeforeChanges)
    }
    if (!insertedCollectionIndicesAfterDeletions.isEmpty) {
        collectionView.insertSections(insertedCollectionIndicesAfterDeletions)
    }
    if (!deletedPhotoPathsBeforeChanges.isEmpty) {
        collectionView.deleteItems(at: deletedPhotoPathsBeforeChanges)
    }
    if (!insertedPhotoPathsAfterDeletions.isEmpty) {
        collectionView.insertItems(at: insertedPhotoPathsAfterDeletions)
    }
}, completion:nil)

guard let changeIndices = fetchResultChangeDetails.changedIndexes else {
    return
}
for indexSetElem in changeIndices {
    let indexPath = IndexPath(item: indexSetElem, section: 0)
    guard let changedCell = collectionView.cellForItem(at: indexPath) else {
        break
    }
    // ... Configure changedCell here ...
}
```

## Topics

### Getting the Changed Fetch Result

[`fetchResultBeforeChanges`](/documentation/Photos/PHFetchResultChangeDetails/fetchResultBeforeChanges)

The original fetch result, without recent changes.

[`fetchResultAfterChanges`](/documentation/Photos/PHFetchResultChangeDetails/fetchResultAfterChanges)

The current fetch result, incorporating recent changes.

### Getting Change Information

[`hasIncrementalChanges`](/documentation/Photos/PHFetchResultChangeDetails/hasIncrementalChanges)

A Boolean value that indicates whether changes to the fetch result can be described incrementally.

[`removedIndexes`](/documentation/Photos/PHFetchResultChangeDetails/removedIndexes)

The indexes from which objects have been removed from the fetch result.

[`removedObjects`](/documentation/Photos/PHFetchResultChangeDetails/removedObjects)

The items that have been removed from the fetch result.

[`insertedIndexes`](/documentation/Photos/PHFetchResultChangeDetails/insertedIndexes)

The indexes where new objects have been inserted in the fetch result.

[`insertedObjects`](/documentation/Photos/PHFetchResultChangeDetails/insertedObjects)

The new items that have been inserted in the fetch result.

[`changedIndexes`](/documentation/Photos/PHFetchResultChangeDetails/changedIndexes)

The indexes of objects in the fetch result whose content or metadata have been updated.

[`changedObjects`](/documentation/Photos/PHFetchResultChangeDetails/changedObjects)

The objects in the fetch result whose content or metadata have been updated.

[`hasMoves`](/documentation/Photos/PHFetchResultChangeDetails/hasMoves)

A Boolean value that indicates whether objects have been rearranged in the fetch result.

[`-  enumerateMovesWithBlock:`](/documentation/Photos/PHFetchResultChangeDetails/enumerateMoves(_:))

Runs the specified block for each case where an object has moved from one index to another in the fetch result.

### Comparing Fetch Results

[`+  changeDetailsFromFetchResult:toFetchResult:changedObjects:`](/documentation/Photos/PHFetchResultChangeDetails/init(from:to:changedObjects:))

Creates a change details object that summarizes the differences between two fetch results.

## Relationships

### Conforms To

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

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

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

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

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

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

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

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

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)