NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init];
ALAssetsLibrary* library = [[ALAssetsLibrary alloc]init];
// NSMutableArray* data = [[NSMutableArray alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup group, BOOL *stop)
{
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop)
{
NSString type = [result valueForProperty:ALAssetPropertyType];
if ([type isEqualToString:ALAssetTypePhoto])
{
ALAssetRepresentation* represent = result.defaultRepresentation;
CGImageRef imgRef = [represent fullResolutionImage];
UIImage* image = [UIImage imageWithCGImage:imgRef scale:represent.scale orientation:(UIImageOrientation)represent.orientation];
NSDictionary* dictionaryURL = [result valueForProperty:ALAssetPropertyURLs];
NSString* url;
for (NSString* str in dictionaryURL)
{
url = [dictionaryURL objectForKey:str];
}
[dictionary setObject:image forKey:url];
}
}];
}
failureBlock:^(NSError *error)
{
NSLog(@"erro!!!");
}];
运行之后没有办法储存到NSDictionary中,调试之后发现所有的block都是在程序后面运行的,所以我无法处理图片。有没有方法可以提前调用这个里面的block或者其他的方法?求大神告知