7

I enumerate all assets groups using ALAssetsLibrary

Here is code:

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

void (^enumerate)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop)
{
    if (group == nil)
    {
        // enumerated all albums..
    }

    // I hot to check if group is Camera Roll ?

};

[library enumerateGroupsWithTypes:ALAssetsGroupAll
                       usingBlock:enumerate
                     failureBlock:nil];

How to check if some current enumerated is CameraRoll?

Edit: As i tested it was always the last, using this enumerating. But i am not sure if it is the rule, are there any references that i missed?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
B.S.
  • 21,660
  • 14
  • 87
  • 109

2 Answers2

14

To get photos from camera roll use ALAssetsGroupSavedPhotos while enumerating assets library:

[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos
                       usingBlock:enumerate
                     failureBlock:nil];

To detect what group you currently get:

if ([[group valueForProperty:@"ALAssetsGroupPropertyType"] intValue] == ALAssetsGroupSavedPhotos)
{
    NSLog(@"Camera roll");
}
Sergey Kuryanov
  • 6,114
  • 30
  • 52
  • I saw about this solution, but i need to know which of my enumerated groups is camera roll, look at the code – B.S. Mar 22 '13 at 12:23
3
    imageArray = [[NSArray alloc] init];
    NSMutableArray*mutableArray =[[NSMutableArray alloc]init];

    NSMutableArray* assetURLDictionaries = [[NSMutableArray alloc] init];

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

void (^enumerate)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop)
{
    if ([[group valueForProperty:@"ALAssetsGroupPropertyType"] intValue] == ALAssetsGroupSavedPhotos)
    {
        NSLog(@"Camera roll");
        [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
            ALAssetRepresentation *rep = [result defaultRepresentation];
            NSLog(@"Asset Name ----> %@",rep.filename);


        }];
    }
    // I hot to check if group is Camera Roll ?

};

 [library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos
                       usingBlock:enumerate
                     failureBlock:nil];