0

I think AssetLibrary's group(album) enumeration api doesn't work anymore on ios 8.02, enumerateGroupsWithTypes:usingBlock: doesn't return the Recently Added group when enumerating all groups and returns empty when calling the Library group(documented as: // The Library group that includes all assets.)

This is my code

+(void)loadCameraRollGroupFromAssetLibrary:(ALAssetsLibrary *)assetLibrary withBlock:(void (^)(BOOL hasPermission, YLCameraRollGroup *cameraRoll))block {
    __block BOOL foundCameraRoll = NO;
    [assetLibrary enumerateGroupsWithTypes:ALAssetsGroupLibrary usingBlock:^(ALAssetsGroup *assetsGroup, BOOL *stop) {
        if(assetsGroup){
            YLCameraRollGroup *group = [[YLCameraRollGroup alloc] initWithAssetsGroup:assetsGroup];
            if(group.isCameraroll){
                NSLog(@"found camera roll");
                *stop = YES; // this fucking stop didn't work, don't know why
                foundCameraRoll = YES;
                block(YES, group);
                return;
            }
        }
        else{
            if(!foundCameraRoll){
                NSLog(@"no camera roll");
                block(NO, nil);
            }
        }
    } failureBlock:^(NSError *error) {
        block(NO, nil);
    }];
}


-(id)initWithAssetsGroup:(ALAssetsGroup *)assetsGroup{
    self = [super init];

    if(self){
        self.name = [assetsGroup valueForProperty:ALAssetsGroupPropertyName];
        NSLog(@"loaded group: %@", self.name);
        self.assetsGroup = assetsGroup;

#if TARGET_IPHONE_SIMULATOR
        self.isCameraroll = [self.name isEqualToString:@"Saved Photos"];
#else
        self.isCameraroll = [self.name isEqualToString:@"Camera Roll"] || [self.name isEqualToString:@"Recently Added"];
#endif
    }

    return self;
}

Does it happen to anyone else?

Eytan Levit
  • 473
  • 9
  • 27
  • What group names do you see when enumerating using `ALAssetsGroupAll`? – Xyand Sep 27 '14 at 20:12
  • I see all groups except for "Recently Added" and "Recent Deleted". This is what changed, on iOS 8.0 it returned the "Recently Added" album. – Eytan Levit Sep 28 '14 at 07:11

1 Answers1

1

ALAssetsGroupLibrary: The Library group that includes all assets that are synced from iTunes.

This isn't the camera roll. Camera roll or Saved Photos for devices without camera should be in ALAssetsGroupSavedPhotos. I think they reverted it back from Recently Added in 8.0.2.

Xyand
  • 4,470
  • 4
  • 36
  • 63