인디노트

PHFetchOptions 본문

소스 팁/Objective C, Swift, iOS, macOS

PHFetchOptions

인디개발자 2018. 4. 29. 15:56

PHFetchOptions

A set of options that affect the filtering, sorting, and management of results that Photos returns when you fetch asset or collection objects.

Overview

Using class methods on the PHAssetPHCollectionPHAssetCollection, and PHCollectionList classes to fetch assets or collections produces a PHFetchResultobject containing the requested objects. The options you specify control which objects the fetch result includes, how those objects are arranged in the fetch result, and how Photos should notify your app of changes to the fetch result.

Photos supports only a restricted set of keys for the predicate and sortDescriptorsproperties. The set of available keys depends on which class you’re using to fetch assets or collections—see Table 1 for the list of keys supported by each class.

Table 1 

Supported predicate and sort descriptor keys

Class for Fetch Method

Supported Keys

PHAsset

SELFlocalIdentifiercreationDatemodificationDatemediaTypemediaSubtypesdurationpixelWidthpixelHeightfavorite (or isFavorite), hidden(or isHidden), burstIdentifier

PHAssetCollection

SELFlocalIdentifierlocalizedTitle (or title), startDateendDateestimatedAssetCount

PHCollectionList

SELFlocalIdentifierlocalizedTitle (or title), startDateendDate

PHCollection (can fetch a mix of PHCollectionList and PHAssetCollectionobjects)

SELFlocalIdentifierlocalizedTitle (or title), startDateendDate


반응형
Comments