NSAssetLibrary works on simulator but not on device - ios

I want to fetch all the images from photo library I'm writing. Following code works on simulator but not on device. Please help me.Thanks in advance.
-(void)getImagesFromDevice
{
arrOfImages = [[NSMutableArray alloc]init];
if (_isForAvtars)
{
}
else
{
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];//ALAssetsGroupAll
NSLog(#"Authirization status:%ld",(long)[ALAssetsLibrary authorizationStatus]);
[library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop)
{
[group setAssetsFilter:[ALAssetsFilter allPhotos]];
if (group != nil)
{
NSLog(#"Gruop is not nil");
NSLog(#"name %#",[group valueForProperty:ALAssetsGroupPropertyName]);
int a = (int)[group numberOfAssets];
NSLog(#"%d",a);
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop)
{
if(result == nil)
{
return;
}
UIImage *img = [UIImage imageWithCGImage:[[result defaultRepresentation] fullScreenImage] scale:1.0 orientation:(UIImageOrientation)[[result valueForProperty:#"ALAssetPropertyOrientation"] intValue]];
if (img != nil)
{
NSLog(#"Add image");
[arrOfImages addObject:img];
}
}];
}
else
{
NSLog(#"Gruop is nil");
[collectionviewPhotosVideos reloadData];
}
}
failureBlock: ^(NSError *error)
{
NSLog(#"No groups");
}
];
}

Related

Read images from a iphone album using ALAssetsLibrary make slow

Read images from a iphone album using ALAssetsLibrary will took 30 seconds to load images of 700. Is there any other version of code using ALAssetsLibrary? My version of Code was below
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
NSLog(#"number of assets = %ld",(long)group.numberOfAssets);
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
if(result == nil) {
return;
}
ALAssetRepresentation *representation = [result defaultRepresentation];
BR_AssetsInfo *info = [[BR_AssetsInfo alloc] init];
info.thumbnail = [UIImage imageWithCGImage:[result thumbnail]];
info.originalImage = [UIImage imageWithCGImage:[representation fullResolutionImage]];
info.imageURLString = [[representation url] absoluteString];
info.isSelected = NO;
for (BR_AssetsInfo *asset in self.selectedAssetsArray) {
if ([asset isEqual:info]) {
info.isSelected = YES;
}
}
[self.assetsDataArray addObject:info];
[self.photosCollectionView reloadData];
}];
} failureBlock:^(NSError *error) {
if (error.code == ALAssetsLibraryAccessUserDeniedError) {
NSLog(#"user denied access, code: %li",(long)error.code);
}else{
NSLog(#"Other error code: %li",(long)error.code);
}
}];

ALAssetsLibrary addAssetsGroupAlbumWithName is not working on iOS 9

I need to add group with name "MyGroupName" in ALAssetsLibrary . So I have used below code.
ALAssetsLibrary * library = [[ALAssetsLibrary alloc] init];
__weak ALAssetsLibrary *lib = library;
[library addAssetsGroupAlbumWithName:#"MyGroupName" resultBlock:^(ALAssetsGroup *group) {
[lib enumerateGroupsWithTypes:ALAssetsGroupAlbum
usingBlock:^(ALAssetsGroup *g, BOOL *stop)
{
if ([[g valueForProperty:ALAssetsGroupPropertyName] isEqualToString:#"MyGroupName"]) {
NSLog(#"group created with name 'MyGroupName'");
}
}failureBlock:^(NSError *error){
NSLog(#"failure %#",error);
}
];
} failureBlock:^(NSError *error) {
NSLog(#"failure %#",error);
}];
but inside "enumerateGroupsWithTypes" , group "g" is always nil in iOS 9.3.1 (iphone 6). its working correctly and group created with name "MyGroupName" on iOS 9.3.1 iphone 5. I want to know why above code is not working on iphone 6 and is there any solution to make it work ?
Please help me. Thanks in advance
1) First Import
#import <Photos/Photos.h>
#import <Photos/PHAsset.h>
#import <AssetsLibrary/AssetsLibrary.h>
2) Set property for ALAsset
#property (nonatomic, strong) ALAssetsLibrary* assetsLibrary;
3) Then allocate ALAsset library in your .m file
- (ALAssetsLibrary*)assetsLibrary
{
if (!_assetsLibrary) {
_assetsLibrary = [[ALAssetsLibrary alloc] init];
[ALAssetsLibrary disableSharedPhotoStreamsSupport];
}
return _assetsLibrary;
}
4 ) Now create method for save image to custom album
- (void)saveImageDatas:(UIImage*)imageDatas toAlbum:(NSString*)album withCompletionBlock:(void(^)(NSError *error))block
{
` if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
NSMutableArray* assets = [[NSMutableArray alloc]init];
PHAssetChangeRequest* assetRequest;
#autoreleasepool {
assetRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:imageDatas];
[assets addObject:assetRequest.placeholderForCreatedAsset];
}
__block PHAssetCollectionChangeRequest* assetCollectionRequest = nil;
PHFetchResult* result = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
[result enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
PHAssetCollection* collection = (PHAssetCollection*)obj;
if ([collection isKindOfClass:[PHAssetCollection class]]) {
if ([[collection localizedTitle] isEqualToString:album]) {
assetCollectionRequest = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:collection];
[assetCollectionRequest addAssets:assets];
*stop = YES;
}
}
}];
if (assetCollectionRequest == nil) {
assetCollectionRequest = [PHAssetCollectionChangeRequest creationRequestForAssetCollectionWithTitle:album];
[assetCollectionRequest addAssets:assets];
}
}
completionHandler:^(BOOL success, NSError *error) {
if (block) {
block(error);
}
}];
}
else {
__weak ALAssetsLibrary* lib = [self assetsLibrary];
[[self assetsLibrary] writeImageDataToSavedPhotosAlbum:UIImageJPEGRepresentation(imageDatas, 1.0) metadata:nil completionBlock:^(NSURL* assetURL, NSError* error) {
if (error != nil) {
return;
}
__block BOOL albumWasFound = NO;
[lib enumerateGroupsWithTypes:ALAssetsGroupAlbum usingBlock:^(ALAssetsGroup* group, BOOL* stop) {
if ([[group valueForProperty:ALAssetsGroupPropertyName] isEqualToString:album]) {
albumWasFound = YES;
[lib assetForURL:assetURL resultBlock:^(ALAsset* asset){
[group addAsset:asset];
if (block) {
block(nil);
}
}failureBlock:^(NSError* error) {
if (block) {
block(error);
}
}];
return;
}
if (group == nil && albumWasFound == NO) {
[lib addAssetsGroupAlbumWithName:album resultBlock:^(ALAssetsGroup* group) {
} failureBlock:^(NSError* error) {
[lib assetForURL:assetURL resultBlock:^(ALAsset* asset){
[group addAsset:asset];
if (block) {
block(nil);
}
}failureBlock:^(NSError* error) {
if (block) {
block(error);
}
}];
}];
}
} failureBlock:^(NSError* error) {
if (block) {
block(error);
}
}];
}];
}
}
5 ) Now call this method to save the image like
[self saveImageDatas:myimage toAlbum:#"MyGroupName" withCompletionBlock:^(NSError *error) {
if (!error) {
NSLog(#"Sucess");
}
}];
"myimage" is your image that you want to save.
Please try this on:
ALAssetsLibrary* libraryFolder = [[ALAssetsLibrary alloc] init];
[libraryFolder addAssetsGroupAlbumWithName:#"My Album" resultBlock:^(ALAssetsGroup *group)
{
NSLog(#"Adding Folder:'My Album', success: %s", group.editable ? "Success" : "Already created: Not Success");
} failureBlock:^(NSError *error)
{
NSLog(#"Error: Adding on Folder");
}];
Or Please check this link also
http://www.touch-code-magazine.com/ios5-saving-photos-in-custom-photo-album-category-for-download/

how to display images by using ALAsseetLibrary

I am accessing the list of images by using the ALAssetLibrary and i got the list of all image in log file . But i am unable to display any image. Can anyone help me through this?
For getting the list of all images my code is here---
- (IBAction)getListOfImages:(id)sender {
NSMutableArray* assetURLDictionaries = [[NSMutableArray alloc] init];
NSMutableArray *xy =[[NSMutableArray alloc]init];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
void (^assetEnumerator)( ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
if(result != nil) {
if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto]) {
[assetURLDictionaries addObject:[result valueForProperty:ALAssetPropertyURLs]];
NSLog(#"result is:%#",result);
NSLog(#"asset URLDictionary is:%#",assetURLDictionaries);
NSURL *url= (NSURL*) [[result defaultRepresentation]url];
[library assetForURL:url
resultBlock:^(ALAsset *asset) {
[xy addObject:[UIImage imageWithCGImage:[[asset defaultRepresentation] fullScreenImage]]];
NSLog(#" xy is:%#",xy);
UIImageView *image =[ [UIImageView alloc ] initWithImage:[xy objectAtIndex:0]];
NSLog(#"image is:%#",image);
}
failureBlock:^(NSError *error){ NSLog(#"test:Fail"); } ];
}
}
};
NSMutableArray *assetGroups = [[NSMutableArray alloc] init];
void (^ assetGroupEnumerator) ( ALAssetsGroup *, BOOL *)= ^(ALAssetsGroup *group, BOOL *stop) {
NSLog(#"hello");
if(group != nil) {
[group enumerateAssetsUsingBlock:assetEnumerator];
[assetGroups addObject:group];
NSLog(#"Number of assets in group :%d",[group numberOfAssets]);
NSLog(#"asset group is:%#",assetGroups);
}
};
assetGroups = [[NSMutableArray alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:assetGroupEnumerator
failureBlock:^(NSError *error) {
NSLog(#"A problem occurred");
}];
}

How to retrieve all the photos and videos in an array from Photos library?

In my code I have tried to fetch all the photos from the photo library and store them in an array.
I want to fetch even the videos also and store them in the same array.
Please tell me how to modify this code for the above requirement.
I have been struggling for this since months as I am a newbie.
-(IBAction)getAllPictures: (id) sender
{
imageArray=[[NSArray alloc] init];
mutableArray =[[NSMutableArray alloc]init];
NSMutableArray* assetURLDictionaries = [[NSMutableArray alloc] init];
library = [[ALAssetsLibrary alloc] init];
void (^assetEnumerator)( ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop)
{
if(result != nil)
{
if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto])
{
if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo])
{
if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeUnknown])
{
[assetURLDictionaries addObject:[result valueForProperty:ALAssetPropertyURLs]];
NSURL *url= (NSURL*) [[result defaultRepresentation]url];
[library assetForURL:url
resultBlock:^(ALAsset *asset)
{
[mutableArray addObject:[UIImage imageWithCGImage:[[asset defaultRepresentation] fullScreenImage]]];
if ([mutableArray count]==count)
{
imageArray=[[NSArray alloc] initWithArray:mutableArray];
[self allPhotosCollected:imageArray];
}
}
failureBlock:^(NSError *error){ NSLog(#"operation was not successfull!");
} ];
}
}
}
}
};
NSMutableArray *assetGroups = [[NSMutableArray alloc] init];
void (^ assetGroupEnumerator) ( ALAssetsGroup *, BOOL *)= ^(ALAssetsGroup *group, BOOL *stop)
{
if(group != nil)
{
[group enumerateAssetsUsingBlock:assetEnumerator];
[assetGroups addObject:group];
count=[group numberOfAssets];
}
};
assetGroups = [[NSMutableArray alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:assetGroupEnumerator
failureBlock:^(NSError *error)
{
NSLog(#"There is an error");
}];
}
-(void)allPhotosCollected:(NSArray*)imgArray
{
//write your code here after getting all the photos from library...
NSLog(#"all pictures are %#",imgArray);
}
You have to use assetLibraries Try this code :-
My code for fetching all the photos from the photo library
- (void)viewDidLoad
{
carousel.type = iCarouselTypeCoverFlow2;
[super viewDidLoad];
xy =[[NSMutableArray alloc]init];
NSMutableArray* assetURLDictionaries = [[NSMutableArray alloc] init];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
void (^assetEnumerator)( ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
if(result != nil) {
if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto]) {
[assetURLDictionaries addObject:[result valueForProperty:ALAssetPropertyURLs]];
NSLog(#"result is:%#",result);
NSLog(#"asset URLDictionary is:%#",assetURLDictionaries);
NSURL *url= (NSURL*) [[result defaultRepresentation]url];
[library assetForURL:url
resultBlock:^(ALAsset *asset) {
[xy addObject:[UIImage imageWithCGImage:[[asset defaultRepresentation] fullScreenImage]]];
NSLog(#" xy is:%#",xy);
image =[ [UIImageView alloc ] initWithImage:[xy objectAtIndex:0]];
NSLog(#"image is:%#",image);
}
failureBlock:^(NSError *error){ NSLog(#"test:Fail"); } ];
}
}
};
NSMutableArray *assetGroups = [[NSMutableArray alloc] init];
void (^ assetGroupEnumerator) ( ALAssetsGroup *, BOOL *)= ^(ALAssetsGroup *group, BOOL *stop) {
NSLog(#"hello");
if(group != nil) {
[group enumerateAssetsUsingBlock:assetEnumerator];
[assetGroups addObject:group];
NSLog(#"Number of assets in group :%d",[group numberOfAssets]);
NSLog(#"asset group is:%#",assetGroups);
}
};
assetGroups = [[NSMutableArray alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:assetGroupEnumerator
failureBlock:^(NSError *error) {NSLog(#"A problem occurred");}];
}
My code for fetching all the videos from the library
- (void)updateAssetsLibrary
{
loadImgView.hidden = NO;
[spinner startAnimating];
//selectVideoBtn .userInteractionEnabled = NO;
assetItems = [NSMutableArray arrayWithCapacity:0];
ALAssetsLibrary *assetLibrary = assetsLibrary;
[assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop)
{
if (group)
{
[group setAssetsFilter:[ALAssetsFilter allVideos]];
[group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop)
{
if (asset)
{
dic = [[NSMutableDictionary alloc] init];
ALAssetRepresentation *defaultRepresentation = [asset defaultRepresentation];
NSString *uti = [defaultRepresentation UTI];
appDelegate.videoURL = [[asset valueForProperty:ALAssetPropertyURLs] valueForKey:uti];
mpVideoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:appDelegate.videoURL];
NSString *title = [NSString stringWithFormat:#"%# %i", NSLocalizedString(#"Video", nil), [assetItems count]+1];
[self performSelector:#selector(imageFromVideoURL)];
[dic setValue:title forKey:kName];
[dic setValue:appDelegate.videoURL forKey:kURL];
AssetBrowserItem *item = [[AssetBrowserItem alloc] initWithURL:appDelegate.videoURL title:title];
[assetItems addObject:item];
[appDelegate.videoURLArray addObject:dic];
NSLog(#"Video has info:%#",appDelegate.videoURLArray);
}
NSLog(#"Values of dictionary==>%#", dic);
//NSLog(#"assetItems:%#",assetItems);
NSLog(#"Videos Are:%#",appDelegate.videoURLArray);
} ];
}
// group == nil signals we are done iterating.
else
{
dispatch_async(dispatch_get_main_queue(), ^{
//[self updateBrowserItemsAndSignalDelegate:assetItems];
loadImgView.hidden = NO;
[spinner stopAnimating];
[loadImgView removeFromSuperview];
//selectVideoBtn .userInteractionEnabled = YES;
});
}
}
failureBlock:^(NSError *error)
{
NSLog(#"error enumerating AssetLibrary groups %#\n", error);
}];
}
- (UIImage *)imageFromVideoURL
{
// result
UIImage *image = nil;
// AVAssetImageGenerator
AVAsset *asset = [[AVURLAsset alloc] initWithURL:appDelegate.videoURL options:nil];;
AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
imageGenerator.appliesPreferredTrackTransform = YES;
// calc midpoint time of video
Float64 durationSeconds = CMTimeGetSeconds([asset duration]);
CMTime midpoint = CMTimeMakeWithSeconds(durationSeconds/2.0, 600);
// get the image from
NSError *error = nil;
CMTime actualTime;
CGImageRef halfWayImage = [imageGenerator copyCGImageAtTime:midpoint actualTime:&actualTime error:&error];
if (halfWayImage != NULL)
{
// CGImage to UIImage
image = [[UIImage alloc] initWithCGImage:halfWayImage];
[dic setValue:image forKey:kImage];
NSLog(#"Values of dictionary==>%#", dic);
NSLog(#"Videos Are:%#",appDelegate.videoURLArray);
CGImageRelease(halfWayImage);
}
return image;
}
- (void)assetsLibraryDidChange:(NSNotification*)changeNotification
{
[self updateAssetsLibrary];
}
- (void)buildAssetsLibrary
{
assetsLibrary = [[ALAssetsLibrary alloc] init];
ALAssetsLibrary *notificationSender = nil;
NSString *minimumSystemVersion = #"4.1";
NSString *systemVersion = [[UIDevice currentDevice] systemVersion];
if ([systemVersion compare:minimumSystemVersion options:NSNumericSearch] != NSOrderedAscending)
notificationSender = assetsLibrary;
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(assetsLibraryDidChange:) name:ALAssetsLibraryChangedNotification object:notificationSender];
[self updateAssetsLibrary];
}
This code will give u list of videos of your iPhone.
It may help you :)
For Future Reference Use this:-
Try this answer very simple and easy to understand
-(void)getFromGallery:(BOOL )IsImages
{
if(self.csCollectionsArray != nil)
[self.csCollectionsArray removeAllObjects];
__block NSMutableDictionary *date = [[NSMutableDictionary alloc] init];
ALAssetsLibrary *csAssetsLibrary = [[ALAssetsLibrary alloc] init];
NSUInteger groupTypes = ALAssetsGroupAlbum | ALAssetsGroupEvent | ALAssetsGroupFaces | ALAssetsGroupSavedPhotos;
[csAssetsLibrary enumerateGroupsWithTypes:groupTypes usingBlock:^(ALAssetsGroup *group, BOOL *stop)
{
if([group numberOfAssets] > 0)
{
if(IsImages)
[group setAssetsFilter:[ALAssetsFilter allPhotos]];
else
[group setAssetsFilter:[ALAssetsFilter allVideos]];
[group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop)
{
if(asset)
{ //1.fetching all assets from device library
//2.Add all fetched assests from library
[date setObject:asset forKey:[asset valueForProperty:ALAssetPropertyDate]];
}
}];
}
else
{ NSLog(#"---> load table -------->");
if(date != nil && date.count > 0)
{ //3.Sort using date by ascending order and moved to dictionary to array
NSArray *sortedKeys = [[date allKeys] sortedArrayUsingSelector: #selector(compare:)];
for (NSString *key in sortedKeys)
[self.csCollectionsArray addObject: [date objectForKey:key]];
//4.Load images into collection view after fetching all datas
[self reloadCollectionView];
if(self.csCollectionView != nil)
[self.csCollectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:([self.csCollectionsArray count] - 1) inSection:0] atScrollPosition:UICollectionViewScrollPositionBottom animated:YES];
}
date = nil;
}
}failureBlock:^(NSError *error)
{
if((csCollectionsArray == nil || [csCollectionsArray count] == 0))
{
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus]; if(status != ALAuthorizationStatusAuthorized)
{
[self showAlertAndCloseUploaderView:#"You can just go to \"Settings\" app (General -> Reset -> Reset Location & Privacy) then come again and click ok when the alert dialog is showing for enable the permission to access the photo library"];
}
}
}];
}

How do i get only the videos using ALAssetsLibrary

I am trying to get videos present from the photo library from the following piece of code.But i also get images list.How do i get list of all videos? what am i doing wrong?
NSMutableArray* assetURLDictionaries = [[NSMutableArray alloc] init];
xy =[[NSMutableArray alloc]init];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
void (^assetEnumerator)( ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
if(result != nil) {
if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) {
[assetURLDictionaries addObject:[result valueForProperty:ALAssetPropertyURLs]];
NSLog(#"result is:%#",result);
NSLog(#"asset URLDictionary is:%#",assetURLDictionaries);
NSURL *url= (NSURL*) [[result defaultRepresentation]url];
[library assetForURL:url
resultBlock:^(ALAsset *asset) {
[xy addObject:[UIImage imageWithCGImage:[[asset defaultRepresentation] fullScreenImage]]];
NSLog(#" xy is:%#",xy);
image =[ [UIImageView alloc ] initWithImage:[xy objectAtIndex:0]];
NSLog(#"image is:%#",image);
}
failureBlock:^(NSError *error){ NSLog(#"test:Fail"); } ];
}
}
};
NSMutableArray *assetGroups = [[NSMutableArray alloc] init];
void (^ assetGroupEnumerator) ( ALAssetsGroup *, BOOL *)= ^(ALAssetsGroup *group, BOOL *stop) {
NSLog(#"hello");
if(group != nil) {
[group enumerateAssetsUsingBlock:assetEnumerator];
[assetGroups addObject:group];
NSLog(#"Number of assets in group :%d",[group numberOfAssets]);
NSLog(#"asset group is:%#",assetGroups);
}
};
assetGroups = [[NSMutableArray alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:assetGroupEnumerator
failureBlock:^(NSError *error) {NSLog(#"A problem occurred");}];
You need to add an ALAssetsFilter to the group during enumeration. Here's a basic example:
ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group) {
[group setAssetsFilter:[ALAssetsFilter allVideos]];
[group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop){
if (asset){
NSDictionary *meta = [[asset defaultRepresentation] metadata];
}
}];
}
} failureBlock:^(NSError *error) {
NSLog(#"error enumerating AssetLibrary groups %#\n", error);
}];
For future reference, the available filters are:
- allPhotos
- allVideos
- allAssets

Resources