使用这些:
- (NSUInteger)updateVideoCount
{
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
if (status==ALAuthorizationStatusDenied) {
[self goToSettingsAlert];
}
videoCount = 0;
totalVideoSize = 0;
ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init];
[assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
[group setAssetsFilter:[ALAssetsFilter allVideos]];
[group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop) {
if (asset)
{
NSString *type = [asset valueForProperty:ALAssetPropertyType];
if ([type isEqualToString:ALAssetTypeVideo])
{
videoCount++;
ALAssetRepresentation *rep = [asset defaultRepresentation];
totalVideoSize += rep.size;
}
}
else
{
}
}];
if(group==nil)
{
[self loadTable];
descTable.hidden = NO;
[descTable reloadData];
}
} failureBlock:^(NSError *error) {
}];
return 0;
}
- (NSUInteger)updatePictureCount
{
photoCount = 0;
totalPictureSize = 0;
ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init];
[assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
[group setAssetsFilter:[ALAssetsFilter allPhotos]];
[group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop) {
if (asset)
{
NSString *type = [asset valueForProperty:ALAssetPropertyType];
if ([type isEqualToString:ALAssetTypePhoto])
{
photoCount++;
ALAssetRepresentation *rep = [asset defaultRepresentation];
totalPictureSize += rep.size;
}
}
else
{
}
}];
if(group==nil)
{
[self loadTable];
descTable.hidden = NO;
[descTable reloadData];
}
} failureBlock:^(NSError *error) {
}];
return 0;
}