Class
ADPhotoManager
public class ADPhotoManager
Main manager class of ADPhotoKit Core. It provide a set of convenience methods to fetch asset from system album. You can use this class to fetch or save asset.
Relationships
Nested Types
ADPhotoManager.AssetResultType
Type of fetch result.
Nested Type Aliases
ADAssetProgressHandler
public typealias ADAssetProgressHandler = (Double, Error?, UnsafeMutablePointer<ObjCBool>, [AnyHashable : Any]?) -> Void
Provide caller a way to be told how much progress has been made prior to delivering the data when it comes from iCloud.
ADAssetCompletionHandler
public typealias ADAssetCompletionHandler = (Any?, [AnyHashable: Any]?, Bool) -> Void
A block that is called after fetch complete.
ADImageCompletionHandler
public typealias ADImageCompletionHandler = (UIImage?, [AnyHashable: Any]?, Bool) -> Void
A block that is called after fetch image complete.
ADDataCompletionHandler
public typealias ADDataCompletionHandler = (Data?, [AnyHashable: Any]?, Bool) -> Void
A block that is called after fetch data complete.
ADLivePhotoCompletionHandler
public typealias ADLivePhotoCompletionHandler = (PHLivePhoto?, [AnyHashable: Any]?, Bool) -> Void
A block that is called after fetch livePhoto complete.
ADPlayItemCompletionHandler
public typealias ADPlayItemCompletionHandler = (AVPlayerItem?, [AnyHashable: Any]?, Bool) -> Void
A block that is called after fetch playItem complete.
ADAVAssertCompletionHandler
public typealias ADAVAssertCompletionHandler = (AVAsset?, [AnyHashable: Any]?, Bool) -> Void
A block that is called after fetch AVAsset complete.
ADFilePathCompletionHandler
public typealias ADFilePathCompletionHandler = (String?, [AnyHashable: Any]?, Bool) -> Void
A block that is called after fetch file path complete.
Methods
allPhotoAlbumList(options:completion:)
public class func allPhotoAlbumList(options: ADAlbumSelectOptions = .default, completion: (([ADAlbumModel]) -> Void))
Fetch all album.
Parameters
Name | Type | Description |
---|---|---|
options | ADAlbumSelectOptions |
Options to set the album type and order. It is |
completion | (([ADAlbumModel]) -> Void) |
Called after finish fetching. |
cameraRollAlbum(options:completion:)
public class func cameraRollAlbum(options: ADAlbumSelectOptions = .default, completion: @escaping ( (ADAlbumModel) -> Void ))
Fetch cameraRoll album.
Parameters
Name | Type | Description |
---|---|---|
options | ADAlbumSelectOptions |
Options to set the album type and order. It is |
completion | @escaping ( (ADAlbumModel) -> Void ) |
Called after finish fetching. |
fetchAssets(in:options:limitCount:)
public class func fetchAssets(in result: PHFetchResult<PHAsset>, options: ADAlbumSelectOptions = .default, limitCount: Int = .max) -> [ADAssetModel]
Fetch assets in album.
Parameters
Name | Type | Description |
---|---|---|
result | PHFetchResult<PHAsset> |
Fetch result associate with album. |
options | ADAlbumSelectOptions |
Options to set the album type and order. It is |
limitCount | Int |
Max count to fetch. |
Returns
Assets in album.
fetch(for:type:progress:completion:)
@discardableResult
public class func fetch(for asset: PHAsset, type: AssetResultType, progress: ADAssetProgressHandler? = nil, completion: @escaping ADAssetCompletionHandler) -> PHImageRequestID?
Fetch assset's data by type.
Parameters
Name | Type | Description |
---|---|---|
asset | PHAsset |
Asset to fetch result. |
type | AssetResultType |
Type of fetch result. |
progress | ADAssetProgressHandler? |
Progress of fetching request. |
completion | @escaping ADAssetCompletionHandler |
Called after fetch result. |
Returns
A numeric identifier for the request. If you need to cancel the request before it completes, pass this identifier to the cancelImageRequest: method.
fetchImage(for:size:resizeMode:synchronous:progress:completion:)
@discardableResult
public class func fetchImage(for asset: PHAsset, size: CGSize? = nil, resizeMode: PHImageRequestOptionsResizeMode = .fast, synchronous: Bool = false, progress: PHAssetImageProgressHandler? = nil, completion: @escaping ADImageCompletionHandler) -> PHImageRequestID
Fetch image for asset.
Parameters
Name | Type | Description |
---|---|---|
asset | PHAsset |
Asset to fetch result. |
size | CGSize? |
Size of the image fetch, If nil, will fetch original image. |
resizeMode | PHImageRequestOptionsResizeMode |
Image resize mode. |
synchronous | Bool |
Return only a single result, blocking until available (or failure). |
progress | PHAssetImageProgressHandler? |
Progress of fetching request. |
completion | @escaping ADImageCompletionHandler |
Called after fetch result. |
Returns
A numeric identifier for the request. If you need to cancel the request before it completes, pass this identifier to the cancelImageRequest: method.
fetchOriginImageData(for:progress:completion:)
@discardableResult
public class func fetchOriginImageData(for asset: PHAsset, progress: PHAssetImageProgressHandler? = nil, completion: @escaping ADDataCompletionHandler) -> PHImageRequestID
Fetch origin data for asset.
Parameters
Name | Type | Description |
---|---|---|
asset | PHAsset |
Asset to fetch result. |
progress | PHAssetImageProgressHandler? |
Progress of fetching request. |
completion | @escaping ADDataCompletionHandler |
Called after fetch result. |
Returns
A numeric identifier for the request. If you need to cancel the request before it completes, pass this identifier to the cancelImageRequest: method.
fetchLivePhoto(for:progress:completion:)
@discardableResult
public class func fetchLivePhoto(for asset: PHAsset, progress: PHAssetImageProgressHandler? = nil, completion: @escaping ADLivePhotoCompletionHandler) -> PHImageRequestID
Fetch livePhoto for asset.
Parameters
Name | Type | Description |
---|---|---|
asset | PHAsset |
Asset to fetch result. |
progress | PHAssetImageProgressHandler? |
Progress of fetching request. |
completion | @escaping ADLivePhotoCompletionHandler |
Called after fetch result. |
Returns
A numeric identifier for the request. If you need to cancel the request before it completes, pass this identifier to the cancelImageRequest: method.
fetchVideo(for:progress:completion:)
@discardableResult
public class func fetchVideo(for asset: PHAsset, progress: PHAssetImageProgressHandler? = nil, completion: @escaping ADPlayItemCompletionHandler) -> PHImageRequestID
Fetch video for asset.
Parameters
Name | Type | Description |
---|---|---|
asset | PHAsset |
Asset to fetch result. |
progress | PHAssetImageProgressHandler? |
Progress of fetching request. |
completion | @escaping ADPlayItemCompletionHandler |
Called after fetch result. |
Returns
A numeric identifier for the request. If you need to cancel the request before it completes, pass this identifier to the cancelImageRequest: method.
fetchAVAsset(forVideo:progress:completion:)
@discardableResult
public class func fetchAVAsset(forVideo asset: PHAsset, progress: PHAssetImageProgressHandler? = nil, completion: @escaping ADAVAssertCompletionHandler) -> PHImageRequestID
Fetch AVAsset for asset.
Parameters
Name | Type | Description |
---|---|---|
asset | PHAsset |
Asset to fetch result. |
progress | PHAssetImageProgressHandler? |
Progress of fetching request. |
completion | @escaping ADAVAssertCompletionHandler |
Called after fetch result. |
Returns
A numeric identifier for the request. If you need to cancel the request before it completes, pass this identifier to the cancelImageRequest: method.
fetchFilePath(asset:completion:)
public class func fetchFilePath(asset: PHAsset, completion: @escaping ADFilePathCompletionHandler)
Fetch file path for asset.
Parameters
Name | Type | Description |
---|---|---|
asset | PHAsset |
Asset to fetch result. |
completion | @escaping ADFilePathCompletionHandler |
Called after fetch result. |
saveImageToAlbum(image:completion:)
public class func saveImageToAlbum(image: UIImage, completion: ( (Bool, PHAsset?) -> Void )? )
Save image to album.
Parameters
Name | Type | Description |
---|---|---|
image | UIImage |
Image to save. |
completion | ( (Bool, PHAsset?) -> Void )? |
Called after image saved. |
saveVideoToAlbum(url:completion:)
public class func saveVideoToAlbum(url: URL, completion: ( (Bool, PHAsset?) -> Void )? )
Save video to album.
Parameters
Name | Type | Description |
---|---|---|
url | URL |
Video asset's path. |
completion | ( (Bool, PHAsset?) -> Void )? |
Called after video saved. |
photoAuthority()
public class func photoAuthority() -> Bool
Check authority access to system album.
Returns
If have authority.