Instance Method

startCachingImagesForAssets:targetSize:contentMode:options:

Prepares image representations of the specified assets for later use.

Declaration

- (void)startCachingImagesForAssets:(NSArray<PHAsset *> *)assets targetSize:(CGSize)targetSize contentMode:(PHImageContentMode)contentMode options:(PHImageRequestOptions *)options;

Parameters

assets

An array of PHAsset objects for which to prepare image representations.

targetSize

The size of the images to be prepared.

contentMode

An option for how to fit the images to the aspect ratio of the requested size. For details, see PHImageContentMode.

options

Options specifying how Photos should handle the request, format the requested images, and notify your app of progress or errors. For details, see PHImageRequestOptions.

Discussion

When you call this method, Photos begins to fetch image data and generates thumbnail images on a background thread. At any time afterward, you can use the requestImageForAsset:targetSize:contentMode:options:resultHandler: method to request individual images from the cache. If Photos has finished preparing a requested image, that method provides the image immediately.

Photos caches images with the exact target size, content mode, and options you specify in this method. If you later request an image with, for example, a different target size than you passed when calling this method, Photos cannot make use of the cache and so it must fetch or generate a new image.

See Also

Preparing Images

- stopCachingImagesForAssets:targetSize:contentMode:options:

Cancels image preparation for the specified assets and options.

- stopCachingImagesForAllAssets

Cancels all image preparation that is currently in progress.