ALAssetsLibrary_Class.pdf ios reference
-
Upload
qamar-saleem -
Category
Documents
-
view
157 -
download
1
description
Transcript of ALAssetsLibrary_Class.pdf ios reference
ALAssetsLibrary Class Reference
Contents
ALAssetsLibrary Class Reference 4Overview 4Tasks 5
Accessing Assets 5Managing Notifications 5Finding Assets 5Enumerating Assets 5Saving Assets 5Managing Asset Groups 6
Class Methods 6authorizationStatus 6disableSharedPhotoStreamsSupport 6
Instance Methods 7addAssetsGroupAlbumWithName:resultBlock:failureBlock: 7assetForURL:resultBlock:failureBlock: 8enumerateGroupsWithTypes:usingBlock:failureBlock: 9groupForURL:resultBlock:failureBlock: 10videoAtPathIsCompatibleWithSavedPhotosAlbum: 11writeImageDataToSavedPhotosAlbum:metadata:completionBlock: 11writeImageToSavedPhotosAlbum:metadata:completionBlock: 12writeImageToSavedPhotosAlbum:orientation:completionBlock: 13writeVideoAtPathToSavedPhotosAlbum:completionBlock: 13
Constants 14ALAssetsGroupType 14Types of Asset 15ALAssetOrientation 16ALAssetsLibraryGroupsEnumerationResultsBlock 17ALAssetsLibraryAssetForURLResultBlock 18ALAssetsLibraryWriteImageCompletionBlock 19ALAssetsLibraryWriteVideoCompletionBlock 19ALAssetsLibraryAccessFailureBlock 20ALAssetsLibraryGroupResultBlock 20ALAuthorizationStatus 21Notification Keys 22
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
2
Error Domain 22Error Codes 23
Notifications 26ALAssetsLibraryChangedNotification 26
Document Revision History 27
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
3
Contents
Inherits from NSObject
Conforms to NSObject (NSObject)
Framework /System/Library/Frameworks/AssetsLibrary.framework
Availability Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h
Related sample code AVCam
AVMovieExporter
AVPlayerDemo
MyImagePicker
PhotosByLocation
OverviewAn instance of ALAssetsLibrary provides access to the videos and photos that are under the control of thePhotos application.
The library includes those that are in the Saved Photos album, those coming from iTunes, and those that weredirectly imported into the device. You use it to retrieve the list of all asset groups and to save images andvideos 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. Thesemethods are all asynchronous because the user may need to be asked to grant access to the data.
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
4
ALAssetsLibrary Class Reference
Tasks
Accessing Assets
+ authorizationStatus (page 6)Returns photo data authorization status for this application.
Managing Notifications
+ disableSharedPhotoStreamsSupport (page 6)Disables shared photo streams notifications and asset retrieval.
Finding Assets
– assetForURL:resultBlock:failureBlock: (page 8)Invokes a given block passing as a parameter an asset identified by a specified file URL.
Enumerating Assets
– enumerateGroupsWithTypes:usingBlock:failureBlock: (page 9)Invokes a given block passing as a parameter each of the asset groups that match the given asset grouptype.
Saving Assets
– writeVideoAtPathToSavedPhotosAlbum:completionBlock: (page 13)Saves a video identified by a given URL to the Saved Photos album.
– videoAtPathIsCompatibleWithSavedPhotosAlbum: (page 11)Returns a Boolean value that indicates whether a video identified by a given URL is compatible with theSaved Photos album.
– writeImageToSavedPhotosAlbum:orientation:completionBlock: (page 13)Saves a given image to the Saved Photos album.
– writeImageDataToSavedPhotosAlbum:metadata:completionBlock: (page 11)Writes given image data and metadata to the Photos Album.
ALAssetsLibrary Class ReferenceTasks
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
5
– writeImageToSavedPhotosAlbum:metadata:completionBlock: (page 12)Writes a given image and metadata to the Photos Album.
Managing Asset Groups
– addAssetsGroupAlbumWithName:resultBlock:failureBlock: (page 7)Adds a new assets group to the library.
– groupForURL:resultBlock:failureBlock: (page 10)Returns an assets group in the result block for a URL previously retrieved from an ALAssetsGroup object.
Class Methods
authorizationStatus
Returns photo data authorization status for this application.
+ (ALAuthorizationStatus)authorizationStatus
Return ValuePhoto data authorization status for this application. For the constants returned, see“ALAuthorizationStatus” (page 21).
DiscussionThis method does not prompt the user for access.
You can use it to detect restricted access and simply hide UI instead of prompting for access.
AvailabilityAvailable in iOS 6.0 and later.
Declared inALAssetsLibrary.h
disableSharedPhotoStreamsSupport
Disables shared photo streams notifications and asset retrieval.
+ (void)disableSharedPhotoStreamsSupport
ALAssetsLibrary Class ReferenceClass Methods
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
6
DiscussionShared photo streams can generate frequent notifications. Use this method to disable support if appropriatefor your app.
Apps compiled against versions of iOS prior to iOS 6.0 do not have support for shared photo streams.
AvailabilityAvailable in iOS 6.0 and later.
Declared inALAssetsLibrary.h
Instance Methods
addAssetsGroupAlbumWithName:resultBlock:failureBlock:
Adds a new assets group to the library.
- (void)addAssetsGroupAlbumWithName:(NSString *)nameresultBlock:(ALAssetsLibraryGroupResultBlock)resultBlockfailureBlock:(ALAssetsLibraryAccessFailureBlock)failureBlock
Parametersname
The name for the new group.
If name conflicts with another assets group with the same name, then the group is not created andresultBlock returns a nil group.
resultBlockThe block invoked after the add operation completes.
For a description of the block, see ALAssetsLibraryAccessFailureBlock (page 20).
failureBlockThe block to invoke if the add operation fails—for example, if the user denies access to the application.
For a description of the block, see ALAssetsGroupFaces (page 15).
DiscussionThe name of the new asset group is name, its type is ALAssetsGroupAlbum (page 15), and the editableproperty is YES.
ALAssetsLibrary Class ReferenceInstance Methods
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
7
This method is asynchronous. When the assets group is added, the user may be asked to confirm the application’saccess to the data; the method, though, returns immediately. You should perform whatever work you wantwith the group in resultBlock.
If the user denies access to the application, or if no application is allowed to access the data, or if the data iscurrently unavailable, the failure block is called.
AvailabilityAvailable in iOS 5.0 and later.
Declared inALAssetsLibrary.h
assetForURL:resultBlock:failureBlock:
Invokes a given block passing as a parameter an asset identified by a specified file URL.
- (void)assetForURL:(NSURL *)assetURLresultBlock:(ALAssetsLibraryAssetForURLResultBlock)resultBlockfailureBlock:(ALAssetsLibraryAccessFailureBlock)failureBlock
ParametersassetURL
An asset URL previously retrieved from an ALAsset object.
resultBlockThe block to invoke using the asset identified by assetURL.
For a description of the block, see ALAssetsLibraryAssetForURLResultBlock (page 18).
failureBlockThe block to invoke if the user denies access to the assets library.
For a description of the block, see ALAssetsLibraryAccessFailureBlock (page 20).
DiscussionThis method is asynchronous. When the asset is requested, the user may be asked to confirm the application'saccess to the library; the method, though, returns immediately. You should perform whatever work you wantwith the asset in resultBlock.
If the user denies access to the application, or if no application is allowed to access the data, the failure blockis called.
AvailabilityAvailable in iOS 4.0 and later.
ALAssetsLibrary Class ReferenceInstance Methods
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
8
Related Sample CodePrintPhoto
Declared inALAssetsLibrary.h
enumerateGroupsWithTypes:usingBlock:failureBlock:
Invokes a given block passing as a parameter each of the asset groups that match the given asset group type.
- (void)enumerateGroupsWithTypes:(ALAssetsGroupType)typesusingBlock:(ALAssetsLibraryGroupsEnumerationResultsBlock)enumerationBlockfailureBlock:(ALAssetsLibraryAccessFailureBlock)failureBlock
Parameterstypes
The types of asset group over which to enumerate.
The value is a bitfield; you can OR together values fromwriteImageDataToSavedPhotosAlbum:metadata:completionBlock: (page 11).
enumerationBlockThe block to invoke using each asset group in turn.
When the enumeration is done, enumerationBlock is invoked with group set to nil.
For a description of the block, see ALAssetsLibraryGroupsEnumerationResultsBlock (page 17).
failureBlockThe block to invoke if the user denies access to the assets library.
For a description of the block, see ALAssetsLibraryAccessFailureBlock (page 20).
DiscussionThe results are passed one by one to the caller by executing the enumeration block.
This method is asynchronous. When groups are enumerated, the user may be asked to confirm the application'saccess to the data; the method, though, returns immediately. You should perform whatever work you wantwith the assets in enumerationBlock.
If the user denies access to the application, or if no application is allowed to access the data, the failureBlockis called.
Special ConsiderationsThis method will fail with error ALAssetsLibraryAccessGloballyDeniedError (page 25) if the user has notenabled Location Services (in Settings > General).
ALAssetsLibrary Class ReferenceInstance Methods
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
9
AvailabilityAvailable in iOS 4.0 and later.
Related Sample CodeAVMovieExporterAVPlayerDemoMTAudioProcessingTap Audio Processor
Declared inALAssetsLibrary.h
groupForURL:resultBlock:failureBlock:
Returns an assets group in the result block for a URL previously retrieved from an ALAssetsGroup object.
- (void)groupForURL:(NSURL *)groupURLresultBlock:(ALAssetsLibraryGroupResultBlock)resultBlockfailureBlock:(ALAssetsLibraryAccessFailureBlock)failureBlock
ParametersgroupURL
The URL for an ALAssetsGroup object.
resultBlockThe block invoked after the access operation completes.
For a description of the block, see ALAssetsLibraryAccessFailureBlock (page 20).
failureBlockThe block to invoke if the access operation fails—for example, if the user denies access to the application.
For a description of the block, see ALAssetsGroupFaces (page 15).
DiscussionThis method is asynchronous: it returns immediately. You should perform whatever work you want with theassets group in resultBlock.
This method is asynchronous. When the assets group is requested, the user may be asked to confirm theapplication’s access to the data; the method, though, returns immediately. You should perform whatever workyou want with the asset group in resultBlock.
If the user denies access to the application, or if no application is allowed to access the data, or if the data iscurrently unavailable, the failure block is called.
ALAssetsLibrary Class ReferenceInstance Methods
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
10
AvailabilityAvailable in iOS 5.0 and later.
Declared inALAssetsLibrary.h
videoAtPathIsCompatibleWithSavedPhotosAlbum:
Returns a Boolean value that indicates whether a video identified by a given URL is compatible with the SavedPhotos album.
- (BOOL)videoAtPathIsCompatibleWithSavedPhotosAlbum:(NSURL *)videoPathURL
ParametersvideoPathURL
An URL that points to a video file.
Return ValueYES if the video identified by videoPathURL is compatible with the Saved Photos album, otherwise NO.
DiscussionThis method returns the same value as UIVideoAtPathIsCompatibleWithSavedPhotosAlbum would forthe same URL.
AvailabilityAvailable in iOS 4.0 and later.
See Also– writeVideoAtPathToSavedPhotosAlbum:completionBlock: (page 13)
Declared inALAssetsLibrary.h
writeImageDataToSavedPhotosAlbum:metadata:completionBlock:
Writes given image data and metadata to the Photos Album.
- (void)writeImageDataToSavedPhotosAlbum:(NSData *)imageData metadata:(NSDictionary*)metadata completionBlock:(ALAssetsLibraryWriteImageCompletionBlock)completionBlock
ParametersimageData
Data for the image to add to the album.
ALAssetsLibrary Class ReferenceInstance Methods
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
11
metadataThe metadata to associate with the image.
completionBlockThe block invoked after the save operation completes.
For a description of the block, see ALAssetsLibraryWriteImageCompletionBlock (page 19).
DiscussionIf there is a conflict between the metadata in the image data and the metadata dictionary, the image datametadata values will be overwritten.
AvailabilityAvailable in iOS 4.1 and later.
Related Sample CodeSquareCam
Declared inALAssetsLibrary.h
writeImageToSavedPhotosAlbum:metadata:completionBlock:
Writes a given image and metadata to the Photos Album.
- (void)writeImageToSavedPhotosAlbum:(CGImageRef)imageRef metadata:(NSDictionary*)metadata completionBlock:(ALAssetsLibraryWriteImageCompletionBlock)completionBlock
ParametersimageRef
The image to add to the album.
metadataThe metadata to associate with the image.
completionBlockThe block invoked after the save operation completes.
For a description of the block, see ALAssetsLibraryWriteImageCompletionBlock (page 19).
DiscussionYou must specify the orientation key in the metadata dictionary to preserve the orientation of the image.
AvailabilityAvailable in iOS 4.1 and later.
ALAssetsLibrary Class ReferenceInstance Methods
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
12
Declared inALAssetsLibrary.h
writeImageToSavedPhotosAlbum:orientation:completionBlock:
Saves a given image to the Saved Photos album.
- (void)writeImageToSavedPhotosAlbum:(CGImageRef)imageReforientation:(ALAssetOrientation)orientationcompletionBlock:(ALAssetsLibraryWriteImageCompletionBlock)completionBlock
ParametersimageRef
The image to save to the Saved Photos album.
orientationThe orientation at which to save the image.
completionBlockThe block invoked after the save operation completes.
For a description of the block, see ALAssetsLibraryWriteImageCompletionBlock (page 19).
DiscussionIf you want to save a UIImage object, you can use the UIImage method CGImage to get a CGImageRef, andcast the image’s imageOrientation to ALAssetOrientation.
AvailabilityAvailable in iOS 4.0 and later.
See Also– writeVideoAtPathToSavedPhotosAlbum:completionBlock: (page 13)
Declared inALAssetsLibrary.h
writeVideoAtPathToSavedPhotosAlbum:completionBlock:
Saves a video identified by a given URL to the Saved Photos album.
- (void)writeVideoAtPathToSavedPhotosAlbum:(NSURL *)videoPathURLcompletionBlock:(ALAssetsLibraryWriteVideoCompletionBlock)completionBlock
ALAssetsLibrary Class ReferenceInstance Methods
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
13
ParametersvideoPathURL
An URL that points to a video file.
completionBlockThe block invoked after the save operation completes.
For a description of the block, see ALAssetsLibraryWriteVideoCompletionBlock (page 19).
Discussion
AvailabilityAvailable in iOS 4.0 and later.
See Also– videoAtPathIsCompatibleWithSavedPhotosAlbum: (page 11)– writeImageToSavedPhotosAlbum:orientation:completionBlock: (page 13)
Related Sample CodeAVCamAVMovieExporterAVSimpleEditoriOSRosyWriterStopNGo for iOS
Declared inALAssetsLibrary.h
Constants
ALAssetsGroupType
A bitfield to identify types of asset.
typedef NSUInteger ALAssetsGroupType;
DiscussionFor possible values, see “Types of Asset” (page 15).
AvailabilityAvailable in iOS 4.0 and later.
ALAssetsLibrary Class ReferenceConstants
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
14
Declared inALAssetsLibrary.h
Types of Asset
Constants to identify types of asset.
enum {ALAssetsGroupLibrary = (1 << 0),ALAssetsGroupAlbum = (1 << 1),ALAssetsGroupEvent = (1 << 2),ALAssetsGroupFaces = (1 << 3),ALAssetsGroupSavedPhotos = (1 << 4),ALAssetsGroupPhotoStream = (1 << 5),ALAssetsGroupAll = 0xFFFFFFFF,
};
ConstantsALAssetsGroupLibrary
The Library group that includes all assets that are synced from iTunes.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsGroupAlbumAll the albums created on the device or synced from iTunes, not including Photo Stream or Shared Streams
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsGroupEventAll events, including those created during Camera Connection Kit import.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsGroupFacesAll the faces albums synced from iTunes.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsGroupSavedPhotosAll the photos in the Camera Roll.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsLibrary Class ReferenceConstants
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
15
ALAssetsGroupPhotoStreamThe PhotoStream album.
In iOS 6.0 and later, this also includes Shared Streams.
Available in iOS 5.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsGroupAllThe same as ORing together all the group types except for ALAssetsGroupLibrary.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetOrientation
Constants to indicate the orientation of an asset.
typedef enum {ALAssetOrientationUp,ALAssetOrientationDown,ALAssetOrientationLeft,ALAssetOrientationRight,ALAssetOrientationUpMirrored,ALAssetOrientationDownMirrored,ALAssetOrientationLeftMirrored,ALAssetOrientationRightMirrored,
} ALAssetOrientation;
ConstantsALAssetOrientationUp
Indicates that the picture is in its default orientation, as shown here.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetOrientationDownIndicates that the picture has been rotated through 180 degrees with respect to
ALAssetOrientationUp (page 16), as shown here.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsLibrary Class ReferenceConstants
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
16
ALAssetOrientationLeftIndicates that the picture has been rotated through 90 degrees counter-clockwise with respect to
ALAssetOrientationUp (page 16), as shown here.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetOrientationRightIndicates that the picture has been rotated through 90 degrees clockwise with respect to
ALAssetOrientationUp (page 16), as shown here.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetOrientationUpMirroredIndicates that the picture has been flipped horizontally with respect to ALAssetOrientationUp (page
16), as shown here.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetOrientationDownMirroredIndicates that the picture has been rotated through 180 degrees with respect to
ALAssetOrientationUp (page 16) and then flipped horizontally, as shown here.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetOrientationLeftMirroredIndicates that the picture has been rotated through 90 degrees counter-clockwise with respect to
ALAssetOrientationUp (page 16) and then flipped vertically, as shown here.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetOrientationRightMirroredIndicates that the picture has been rotated through 90 degrees clockwise with respect to
ALAssetOrientationUp (page 16) and then flipped vertically, as shown here.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsLibraryGroupsEnumerationResultsBlock
Signature for the block executed when a match is found during enumeration usingenumerateGroupsWithTypes:usingBlock:failureBlock: (page 9).
ALAssetsLibrary Class ReferenceConstants
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
17
typedef void (^ALAssetsLibraryGroupsEnumerationResultsBlock)(ALAssetsGroup *group, BOOL*stop);
DiscussionThe block parameters are defined as follows:
groupThe current asset group in the enumeration.
stopA pointer to a boolean value; set the value to YES to stop enumeration.
AvailabilityAvailable in iOS 4.0 and later.
Declared inALAssetsLibrary.h
ALAssetsLibraryAssetForURLResultBlock
Signature for the block executed if the user has granted access to the caller to access the data managed by theframework in assetForURL:resultBlock:failureBlock: (page 8).
typedef void (^ALAssetsLibraryAssetForURLResultBlock)(ALAsset *asset);
DiscussionThe block parameter is defined as follows:
assetThe asset identified by the URL parameter in assetForURL:resultBlock:failureBlock: (page 8).
If the asset is not found, asset is nil.
AvailabilityAvailable in iOS 4.0 and later.
Declared inALAssetsLibrary.h
ALAssetsLibrary Class ReferenceConstants
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
18
ALAssetsLibraryWriteImageCompletionBlock
SignaturefortheblockexecutedwhenwriteImageToSavedPhotosAlbum:orientation:completionBlock: (page13) completes.
typedef void (^ALAssetsLibraryWriteImageCompletionBlock)(NSURL *assetURL, NSError *error);
DiscussionThe block parameters are defined as follows:
assetURLAn URL that identifies the saved image file.
If the image is not saved, assetURL is nil.
errorIf the image is not saved, an error object that describes the reason for failure, otherwise nil.
AvailabilityAvailable in iOS 4.0 and later.
Declared inALAssetsLibrary.h
ALAssetsLibraryWriteVideoCompletionBlock
Signature for the block executed when writeVideoAtPathToSavedPhotosAlbum:completionBlock: (page13) completes.
typedef void (^ALAssetsLibraryWriteVideoCompletionBlock)(NSURL *assetURL, NSError *error);
DiscussionThe block parameters are defined as follows:
assetURLAn URL that identifies the saved video file.
If the video is not saved, assetURL is nil.
errorIf the video is not saved, an error object that describes the reason for failure, otherwise nil.
AvailabilityAvailable in iOS 4.0 and later.
ALAssetsLibrary Class ReferenceConstants
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
19
Declared inALAssetsLibrary.h
ALAssetsLibraryAccessFailureBlock
Signature for the block executed if the user does not grant access to the caller to access the data managed by theframework.
typedef void (^ALAssetsLibraryAccessFailureBlock)(NSError *error);
DiscussionThe block parameter is defined as follows:
errorAn error object that describes why access to the library failed.
This block type is used by assetForURL:resultBlock:failureBlock: (page 8) andenumerateGroupsWithTypes:usingBlock:failureBlock: (page 9).
AvailabilityAvailable in iOS 4.0 and later.
Declared inALAssetsLibrary.h
ALAssetsLibraryGroupResultBlock
Signature for the block executed if the user grants access to the caller to access the data managed by theframework..
typedef void (^ALAssetsLibraryGroupResultBlock)(ALAssetsGroup *group));
DiscussionThe block parameter is defined as follows:
groupThe group that was added to the assets library.
If the group is not found or not created (for example, because of a name collision), group is nil.
ALAssetsLibrary Class ReferenceConstants
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
20
This block type is used by addAssetsGroupAlbumWithName:resultBlock:failureBlock: (page 7) andgroupForURL:resultBlock:failureBlock: (page 10).
AvailabilityAvailable in iOS 5.0 and later.
Declared inALAssetsLibrary.h
ALAuthorizationStatus
Constants to indicate authorization status.
typedef NS_ENUM(NSInteger,ALAuthorizationStatus) {ALAuthorizationStatusNotDetermined = 0,ALAuthorizationStatusRestricted,ALAuthorizationStatusDenied,ALAuthorizationStatusAuthorized };
ConstantsALAuthorizationStatusNotDetermined
User has not yet made a choice with regards to this application.
Available in iOS 6.0 and later.
Declared in ALAssetsLibrary.h.
ALAuthorizationStatusRestrictedThis application is not authorized to access photo data.
The user cannot change this application’s status, possibly due to active restrictions such as parentalcontrols being in place.
Available in iOS 6.0 and later.
Declared in ALAssetsLibrary.h.
ALAuthorizationStatusDeniedUser has explicitly denied this application access to photos data.
Available in iOS 6.0 and later.
Declared in ALAssetsLibrary.h.
ALAuthorizationStatusAuthorizedUser has authorized this application to access photos data.
Available in iOS 6.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsLibrary Class ReferenceConstants
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
21
Notification Keys
KeysusedtogetvaluesfromtheuserinformationdictionaryoftheALAssetsLibraryChangedNotification (page26) notification.
NSString * const ALAssetLibraryUpdatedAssetsKey;NSString * const ALAssetLibraryInsertedAssetGroupsKey;NSString * const ALAssetLibraryUpdatedAssetGroupsKey;NSString * const ALAssetLibraryDeletedAssetGroupsKey;
ConstantsALAssetLibraryUpdatedAssetsKey
Value is a set of NSURL objects identifying the assets that were updated.
Available in iOS 6.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetLibraryInsertedAssetGroupsKeyValue is a set of NSURL objects identifying the assets that were inserted.
Available in iOS 6.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetLibraryUpdatedAssetGroupsKeyValue is a set of NSURL objects identifying the asset groups that were updated.
Available in iOS 6.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetLibraryDeletedAssetGroupsKeyValue is a set of NSURL objects identifying the asset groups that were deleted.
Available in iOS 6.0 and later.
Declared in ALAssetsLibrary.h.
DiscussionAssets that are modified use the ALAssetLibraryUpdatedAssetsKey key. Assets that are inserted or deleteduse the ALAssetLibraryUpdatedAssetGroupsKey key for the asset group that contains the asset.
Assets and asset groups that have no strong references are omitted from the notification’s user informationdictionary.
Error Domain
Constant for the AssetsLibrary domain.
ALAssetsLibrary Class ReferenceConstants
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
22
NSString *const ALAssetsLibraryErrorDomain;
ConstantsALAssetsLibraryErrorDomain
Constant used by NSError to distinguish errors belonging to the AssetsLibrary domain.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
Error Codes
AssetsLibrary-related error codes
enum {ALAssetsLibraryUnknownError = -1,
ALAssetsLibraryWriteFailedError = -3300,ALAssetsLibraryWriteBusyError = -3301,ALAssetsLibraryWriteInvalidDataError = -3302,ALAssetsLibraryWriteIncompatibleDataError = -3303,ALAssetsLibraryWriteDataEncodingError = -3304,ALAssetsLibraryWriteDiskSpaceError = -3305,
ALAssetsLibraryDataUnavailableError = -3310,
ALAssetsLibraryAccessUserDeniedError = -3311,ALAssetsLibraryAccessGloballyDeniedError = -3312,
};
ConstantsALAssetsLibraryUnknownError
The reason for the error is unknown.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsLibraryWriteFailedErrorThe attempt to write data failed.
This error may be returned in the completion block forwriteVideoAtPathToSavedPhotosAlbum:completionBlock: (page 13) andwriteImageToSavedPhotosAlbum:orientation:completionBlock: (page 13) as well as the completionselector for UIImageWriteToSavedPhotosAlbum and UISaveVideoAtPathToSavedPhotosAlbum.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsLibrary Class ReferenceConstants
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
23
ALAssetsLibraryWriteBusyErrorWriting was already busy when the attempt to write was made.
You should attempt the write again.
This error may be returned in the completion block forwriteVideoAtPathToSavedPhotosAlbum:completionBlock: (page 13) andwriteImageToSavedPhotosAlbum:orientation:completionBlock: (page 13) as well as the completionselector for UIImageWriteToSavedPhotosAlbum and UISaveVideoAtPathToSavedPhotosAlbum.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsLibraryWriteInvalidDataErrorThe data was invalid.
This error may be returned in the completion block forwriteVideoAtPathToSavedPhotosAlbum:completionBlock: (page 13) andwriteImageToSavedPhotosAlbum:orientation:completionBlock: (page 13) as well as the completionselector for UIImageWriteToSavedPhotosAlbum and UISaveVideoAtPathToSavedPhotosAlbum.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsLibraryWriteIncompatibleDataErrorThe data contained incompatible data.
This error may be returned in the completion block forwriteVideoAtPathToSavedPhotosAlbum:completionBlock: (page 13) andwriteImageToSavedPhotosAlbum:orientation:completionBlock: (page 13) as well as the completionselector for UIImageWriteToSavedPhotosAlbum and UISaveVideoAtPathToSavedPhotosAlbum.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsLibraryWriteDataEncodingErrorThe data contained data with the wrong encoding.
This error may be returned in the completion block forwriteVideoAtPathToSavedPhotosAlbum:completionBlock: (page 13) andwriteImageToSavedPhotosAlbum:orientation:completionBlock: (page 13) as well as the completionselector for UIImageWriteToSavedPhotosAlbum and UISaveVideoAtPathToSavedPhotosAlbum.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsLibrary Class ReferenceConstants
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
24
ALAssetsLibraryWriteDiskSpaceErrorThere was not enough space on the disk to write the data.
This error may be returned in the completion block forwriteVideoAtPathToSavedPhotosAlbum:completionBlock: (page 13) andwriteImageToSavedPhotosAlbum:orientation:completionBlock: (page 13) as well as the completionselector for UIImageWriteToSavedPhotosAlbum and UISaveVideoAtPathToSavedPhotosAlbum.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsLibraryDataUnavailableErrorThe data was not available.
This error may be returned in the ALAssetsLibraryAccessFailureBlock (page 20) forenumerateGroupsWithTypes:usingBlock:failureBlock: (page 9) andassetForURL:resultBlock:failureBlock: (page 8); and in the completion blocks forwriteImageToSavedPhotosAlbum:orientation:completionBlock: (page 13) andwriteImageToSavedPhotosAlbum:orientation:completionBlock: (page 13); as well as in the completionselector for UIImageWriteToSavedPhotosAlbum and UISaveVideoAtPathToSavedPhotosAlbum.
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsLibraryAccessUserDeniedErrorThe user denied access to the library.
This error may be returned in the ALAssetsLibraryAccessFailureBlock (page 20) block forenumerateGroupsWithTypes:usingBlock:failureBlock: (page 9) andassetForURL:resultBlock:failureBlock: (page 8).
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsLibraryAccessGloballyDeniedErrorAccess to the library was denied globally.
This error may be returned in the ALAssetsLibraryAccessFailureBlock (page 20) block forenumerateGroupsWithTypes:usingBlock:failureBlock: (page 9) andassetForURL:resultBlock:failureBlock: (page 8).
Available in iOS 4.0 and later.
Declared in ALAssetsLibrary.h.
ALAssetsLibrary Class ReferenceConstants
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
25
Notifications
ALAssetsLibraryChangedNotification
Sent when the contents of the assets library have changed from under the app that is using the data.
In iOS 4.0, the notification’s object is nil. In iOS 4.1 and later, the notification object is the library object thatposted the notification.
In iOS 6.0 and later, the user information dictionary describes what changed: ● If the user information dictionary is nil, reload all assets and asset groups.
● If the user information dictionary an empty dictionary, there is no need to reload assets and asset groups.
● If the user information dictionary is not empty, reload the effected assets and asset groups. For the keysused, see “Notification Keys” (page 22).
This notification is sent on an arbitrary thread.
AvailabilityAvailable in iOS 4.0 and later.
Declared inALAssetsLibrary.h
ALAssetsLibrary Class ReferenceNotifications
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
26
This table describes the changes to ALAssetsLibrary Class Reference .
NotesDate
Added to the discussion of ALAssetsLibraryAccessGloballyDeniedError.2012-12-13
Updated with API to support data privacy.2012-09-19
Updated for iOS v5.0.2011-10-12
Noted that enumerateGroupsWithTypes:usingBlock:failureBlock: fails ifthe user has not enabled Location Services.
2011-04-28
Updated for iOS v4.2010-07-01
First version of a document that describes the object that represents thevideos and photos in the Photos application.
2010-05-24
2012-12-13 | Copyright © 2012 Apple Inc. All Rights Reserved.
27
Document Revision History
Apple Inc.Copyright © 2012 Apple Inc.All rights reserved.
No part of this publication may be reproduced,stored in a retrieval system, or transmitted, in anyform or by any means, mechanical, electronic,photocopying, recording, or otherwise, withoutprior written permission of Apple Inc., with thefollowing exceptions: Any person is herebyauthorized to store documentation on a singlecomputer for personal use only and to printcopies of documentation for personal useprovided that the documentation containsApple’s copyright notice.
No licenses, express or implied, are granted withrespect to any of the technology described in thisdocument. Apple retains all intellectual propertyrights associated with the technology describedin this document. This document is intended toassist application developers to developapplications only for Apple-labeled computers.
Apple Inc.1 Infinite LoopCupertino, CA 95014408-996-1010
Apple, the Apple logo, and iTunes are trademarksof Apple Inc., registered in the U.S. and othercountries.
iOS is a trademark or registered trademark ofCisco in the U.S. and other countries and is usedunder license.
Even though Apple has reviewed this document,APPLE MAKES NO WARRANTY OR REPRESENTATION,EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THISDOCUMENT, ITS QUALITY, ACCURACY,MERCHANTABILITY, OR FITNESS FOR A PARTICULARPURPOSE.ASARESULT, THISDOCUMENT ISPROVIDED“AS IS,” AND YOU, THE READER, ARE ASSUMING THEENTIRE RISK AS TO ITS QUALITY AND ACCURACY.
IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT,INDIRECT, SPECIAL, INCIDENTAL, ORCONSEQUENTIALDAMAGES RESULTING FROM ANY DEFECT ORINACCURACY IN THIS DOCUMENT, even if advised ofthe possibility of such damages.
THE WARRANTY AND REMEDIES SET FORTH ABOVEARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORALOR WRITTEN, EXPRESS OR IMPLIED. No Apple dealer,agent, or employee is authorized to make anymodification, extension, or addition to this warranty.
Some states do not allow the exclusion or limitationof implied warranties or liability for incidental orconsequential damages, so the above limitation orexclusion may not apply to you. This warranty givesyou specific legal rights, and youmay also have otherrights which vary from state to state.