Question

My code was working on OS 4.3 but with 5 i am getting warnings regarding ALAssetsGroup for the ALAssetsGroup i dont get any methods for it so i get instance not found for the enumerate see code

 void (^assetEnumerator)(ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop)
{
    if(result != nil)
    {
        [assets addObject:result];
    }
};


// Create instance of the Assets Library.
void (^assetGroupEnumerator)( ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop) {
    if(group != nil)
    {
        [group enumerateAssetsUsingBlock:assetEnumerator];
    }
};



assets = [[NSMutableArray alloc] init];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAlbum
                       usingBlock:assetGroupEnumerator
                     failureBlock: ^(NSError *error) {
                         NSLog(@"failureBlock:%@",error);
                     }];    

Any help will be appreciated Thanks

Was it helpful?

Solution

as of iOS 5 more Assets-Library methods are asynchronous and want to be called from the main-thread. Make sure you call your 2nd block enumerating the group from the main-thread using dispatch_async on the main-queue.

Cheers,

Hendrik

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top