PHFetchResult
An ordered list of assets or collections returned from a Photos fetch method.
Declaration
class PHFetchResult<ObjectType> where ObjectType : AnyObjectMentioned in
Overview
When you use class methods on the PHAsset, PHCollection, PHAssetCollection, and PHCollectionList classes to retrieve objects, Photos provides the resulting objects in a fetch result. You access the contents of a fetch result with the same methods and conventions used by the NSArray class. Unlike an NSArray object, however, a PHFetchResult object dynamically loads its contents from the Photos library as needed, providing optimal performance even when handling a large number of results.
A fetch result provides thread-safe access to its contents. After a fetch, the fetch result’s count value is constant, and all objects in the fetch result keep the same localIdentifier value. (To get updated content for a fetch, register a change observer with the shared PHPhotoLibrary object.)
A fetch result caches its contents, keeping a batch of objects around the most recently accessed index. Because objects outside of the batch are no longer cached, accessing these objects results in refetching those objects. This process can result in changes to values previously read from those objects.