ALAssetsLibrary Class Reference
特殊注意事项:此方法将失败并出现错误 如果用户尚未启用,则为ALAssetsLibraryAccessGloballyDeniedError 位置服务(在设置>常规中)。
ALAssetsLibraryAccessGloballyDeniedError
错误的代码。`
-(void)requestAccessForAssetsLibrary {
ALAssetsLibrary *aLib = [[ALAssetsLibrary alloc]init];
void(^assetsGroupEnumerationBlock)(ALAssetsGroup*, BOOL*) = ^(ALAssetsGroup *groups, BOOL *stop) {
*stop = YES;
NSDictionary *alAuthDict = @{@"alAssetsAuthStatusDictKey" : [NSString stringWithFormat:@"%d",[self getALAssetAuthorizationStatus]]};
[[NSNotificationCenter defaultCenter]postNotificationName:@"alAssetsStatusNotificationName" object:nil userInfo:alAuthDict];
};
void(^failureBLock)(NSError*) = ^(NSError *error) {
NSDictionary *alAuthDict = @{@"alAssetsAuthStatusDictKey" : [NSString stringWithFormat:@"%d",[self getALAssetAuthorizationStatus]]};
[[NSNotificationCenter defaultCenter]postNotificationName:@"alAssetsStatusNotificationName" object:nil userInfo:alAuthDict];
};
[aLib enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:assetsGroupEnumerationBlock failureBlock:failureBLock];
}
`