An instance of ALAssetsLibrary provides access to the videos and photos that are under the control of the Photos application.


class ALAssetsLibrary : NSObject


The library includes those that are in the Saved Photos album, those coming from iTunes, and those that were directly imported into the device. You use it to retrieve the list of all asset groups and to save images and videos into the Saved Photos album.

You create an instance of ALAssetsLibrary using alloc and init:

ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];

The lifetimes of objects you get back from a library instance are tied to the lifetime of the library instance.

Many of the methods declared by ALAssetsLibrary take blocks for failure and success as arguments. These methods are all asynchronous because the user may need to be asked to grant access to the data.


Accessing Assets

class func authorizationStatus() -> ALAuthorizationStatus

Returns photo data authorization status for this application.

Managing Notifications

class func disableSharedPhotoStreamsSupport()

Disables shared photo streams notifications and asset retrieval.

Finding Assets

func asset(for: URL!, resultBlock: ALAssetsLibraryAssetForURLResultBlock!, failureBlock: ALAssetsLibraryAccessFailureBlock!)

Invokes a given block passing as a parameter an asset identified by a specified file URL.


typealias ALAssetsGroupType

A bitfield to identify types of asset.

Types of Asset

Constants to identify types of asset.

enum ALAssetOrientation

Constants to indicate the orientation of an asset.

typealias ALAssetsLibraryGroupsEnumerationResultsBlock

Signature for the block executed when a match is found during enumeration using enumerateGroups(withTypes:using:failureBlock:).

typealias ALAssetsLibraryAssetForURLResultBlock

Signature for the block executed if the user has granted access to the caller to access the data managed by the framework in asset(for:resultBlock:failureBlock:).

typealias ALAssetsLibraryAccessFailureBlock

Signature for the block executed if the user does not grant access to the caller to access the data managed by the framework.

typealias ALAssetsLibraryGroupResultBlock

Signature for the block executed if the user grants access to the caller to access the data managed by the framework..

enum ALAuthorizationStatus

Constants to indicate authorization status.

Notification Keys

Keys used to get values from the user information dictionary of the ALAssetsLibraryChanged notification.

Error Domain

Constant for the AssetsLibrary domain.

Error Codes

AssetsLibrary-related error codes


static let ALAssetsLibraryChanged: NSNotification.Name

Sent when the contents of the assets library have changed from under the app that is using the data.


Inherits From

Conforms To