It code is working on simulator but on device is not working and i'm not getting gallery images from device
imageArray=[[NSArray alloc] init];
name=[[NSArray alloc]init];
mutableArray =[[NSMutableArray alloc]init];
// self.title = [library valueForProperty:ALAssetsGroupPropertyName];
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
NSMutableArray* assetURLDictionaries = [[NSMutableArray alloc] init];
library = [[ALAssetsLibrary alloc] init];
void (^assetEnumerator)( ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
NSLog(@"%zd",result);
if(result != nil) {
if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto]) {
[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 ) {
// name=[[NSArray alloc]initWithArray:lisk];
imageArray=[[NSArray alloc] initWithArray:mutableArray];
_listImageArrayFromGallery=[[NSMutableArray alloc]init];
for (int i=0; i<imageArray.count; i++) {
[_listImageArrayFromGallery addObject:[imageArray objectAtIndex:i]];
}
NSLog(@"ListPic%@",_listImageArrayFromGallery);
loadedCards = [[NSMutableArray alloc] init];
allCards = [[NSMutableArray alloc] init];
cardsLoadedIndex = 0;
[self loadCards];
// [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];
//[assetGrpImage addObject:assetGroups];
//assetGrpImage=[assetGrpImage valueForKey:@"Camera Roll"];
}
};
assetGroups = [[NSMutableArray alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:assetGroupEnumerator
failureBlock:^(NSError *error) {NSLog(@"There is an error");}];
In this code I'm getting simulator gallery images, but on device I'm not getting gellery images.