---
title: "init(from:to:changedObjects:)"
framework: photos
role: symbol
role_heading: Initializer
path: "photos/phfetchresultchangedetails/init(from:to:changedobjects:)"
---

# init(from:to:changedObjects:)

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

## Declaration

```swift
convenience init(from fromResult: PHFetchResult<ObjectType>, to toResult: PHFetchResult<ObjectType>, changedObjects: [ObjectType])
```

## Parameters

- `fromResult`: A fetch result to be treated as the “before” state in the resulting change details object.
- `toResult`: A fetch result to be treated as the “after” state in the resulting change details object.
- `changedObjects`: An collection of objects to manually note as changed between the two fetch results.

## Return Value

Return Value A change details object.

## Discussion

Discussion Typically, you use the PHChange class to retrieve PHFetchResultChangeDetails objects describing any changes that have occurred since you performed a fetch, but you can also use this method to get a change details object that summarizes the difference between two arbitrary PHFetchResult objects. In this case, Photos cannot automatically determine when the same objects are present in both fetch results but those objects’ content has changed, so the changedIndexes and changedObjects properties are empty. However, you can use the changedObjects parameter to manually note objects as changed. For example, consider a view controller that maintains a base fetch result representing a list of albums, and a transient collection that filters the list according to the user’s search terms. For this workflow, you might use a method like the following: Because transient collections are not stored in the photo library, Photos cannot provide change details for fetch results against a transient collection. The photoLibraryDidChange(_:) method provides change details for the base fetch result, which you can use to request change details for the filtered fetch result: Because you provide the changedObjects array from the original change details when calling the init(from:to:changedObjects:) method, Photos can provide a summary of differences between the filtered fetch results that includes changedIndexes and changedObjects information. You can then use this information for efficiently updating your app’s interface — for an example of how to do this, see PHPhotoLibraryChangeObserver.
