views:

23

answers:

1

Hi, i came across the following piece of code which loads everything from photo album but what should i do if i only wanted to load the video type in the photo album on a table?
thanks in advance.

void (^assetEnumerator)(struct ALAsset *,NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop){ if(result != nil){ NSLog(@"Asset:%@", result); [Asset addObject:result]; } };

void (^assetGroupEnumerator)(struct ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop){
    if(group != nil){
        [group enumerateAssetsUsingBlock: assetEnumerator];
    }

    [self.tableView reloadData];


};

Asset = [[NSMutableArray alloc] init];
ALAssetsLibrary *Library = [[ALAssetsLibrary alloc] init];
[Library enumerateGroupsWithTypes:ALAssetsGroupAlbum
                       usingBlock:assetGroupEnumerator 
                     failureBlock:^(NSError *error){
                         NSLog(@"error occurred");
                     }];
A: 

Have a look at the -valueForProperty: instance method of ALAsset. Specifically, in your example with ALAsset *result:

if ([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) {
    // asset is a video
}
Sedate Alien
hi Thanks for the help. it work great.
tan