Instance Method


Returns detailed change information for a fetch result.


func changeDetails(for fetchResult: PHFetchResult<AnyObject>) -> PHFetchResultChangeDetails<PHObject>?



A fetch result.

Return Value

A change details object, or nil if there have been no changes affecting the fetch result’s contents.


When Photos calls your change observer’s photoLibraryDidChange(_:) method, call the changeDetails(for:)changeDetails(for:) method to get detailed change information about the results of a fetch you’ve previously performed. If there have been any changes in the Photos library affecting the fetch, the resulting PHFetchResultChangeDetails object tells you if any contents in the fetch result have been added, removed, or changed since you fetched it. If there have been no changes since you performed the fetch, this method returns nil.

Typically, if your app displays the members of a collection (such as an album or moment), you use a method such as fetchAssets(in:options:) to retrieve those members and then keep the resulting PHFetchResult object. You can then pass that fetch result to this method to learn about changes to the collection, such as whether new members have been added to it (and which indexes to insert them at in your UI).

To find out about changes to an object’s properties, such as a collection’s title or an asset’s metadata, use the changeDetails(for:) method.

See Also

Getting Change Details

func changeDetails<T>(for: T) -> PHObjectChangeDetails<T>?

Returns detailed change information for the specified asset or collection.

func changeDetails<T>(for: PHFetchResult<T>) -> PHFetchResultChangeDetails<T>?

Returns detailed change information for a fetch result.