/**
* 获取系统照片所占空间大小
*/
- (void)getSystemPhotosSize
{
__block unsigned long long photosSize = 0;
ALAssetsLibrary *library=[[ALAssetsLibrary alloc]init];
void (^assetEnumerator)( ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
if(result != nil) {
if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto]) {
photosSize += [[result defaultRepresentation]size];
}
} else {
UILabel *photosSizeLabel = (UILabel *)[_systemInformationBjView viewWithTag:222];
photosSizeLabel.text = [self formattedSystemInfo:photosSize];
}
};
void (^ assetGroupEnumerator)( ALAssetsGroup *, BOOL *)= ^(ALAssetsGroup *group, BOOL *stop) {
if(group != nil) {
[group enumerateAssetsUsingBlock:assetEnumerator];
}
};
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:assetGroupEnumerator
failureBlock:^(NSError *error) {
UILabel *photosSizeLabel = (UILabel *)[_systemInformationBjView viewWithTag:222];
photosSizeLabel.text = @"禁止获取";
}];
}
/**
* 获取系统视频所占空间大小
*/
- (void)getSystemVideoSize
{
__block unsigned long long videoSizeTemp = 0;
ALAssetsLibrary *library=[[ALAssetsLibrary alloc]init];
void (^assetEnumerator)( ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
if(result != nil) {
if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) {
videoSizeTemp += [[result defaultRepresentation] size];
}
} else {
UILabel *videoSizeLabel = (UILabel *)[_systemInformationBjView viewWithTag:444];
videoSizeLabel.text = [self formattedSystemInfo:videoSizeTemp];
}
};
void (^ assetGroupEnumerator)( ALAssetsGroup *, BOOL *)= ^(ALAssetsGroup *group, BOOL *stop) {
if(group != nil) {
[group enumerateAssetsUsingBlock:assetEnumerator];
}
};
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:assetGroupEnumerator
failureBlock:^(NSError *error) {
UILabel *videoSizeLabel = (UILabel *)[_systemInformationBjView viewWithTag:444];
videoSizeLabel.text = @"禁止获取";
}];
}