Instance Method

countOfAssetsWithMediaType:

Returns the number of assets in the fetch result of a specified type.

Declaration

- (NSUInteger)countOfAssetsWithMediaType:(PHAssetMediaType)mediaType;

Parameters

mediaType

The type of assets to count, such as image or video. See PHAssetMediaType.

Return Value

The number of assets in the fetch result of the specified type.

Discussion

The first time you call this method, Photos enumerates the contents of the fetch result to count those of the specified type, then caches the result. Subsequent calls with the same mediaType parameter return the cached value.

This method counts only the PHAsset objects in a fetch result. If a fetch result contains only PHAssetCollection or PHCollectionList objects, the return value is 0.

See Also

Querying a Fetch Result

- containsObject:

Returns whether the specified object is present in the fetch result.

count

The number of objects in the fetch result.

firstObject

The first object in the fetch result.

lastObject

The last object in the fetch result.

- objectAtIndex:

Returns the object located at the specified index.

- objectAtIndexedSubscript:

Returns the object located at the specified index.

- objectsAtIndexes:

Returns an array containing the objects in the fetch result at the indexes in the specified index set.