Reputation: 473
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?
Upvotes: 0
Views: 277
Reputation: 4488
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.
Upvotes: 1