我想获取相册里的所有图片进入一个NSDictionary里面

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!!!");
 }];
以上是我写的代码,运行之后发现没有办法放进去,调试之后发现应该是函数中的block运行的时候已经是所有函数运行之后了。
只有在所有程序运行完了之后才运行block所以我就没有办法处理NSDictionary里面的照片了,求大神告知解决方法。
有没有方法可以提前调用那个block?
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值