为什么这个数组没有被填充?

时间:2013-04-05 13:13:12

标签: objective-c arrays multithreading alassetslibrary

即使 assetsEnumerator block 在另一个线程中执行,我的图像仍然需要很长时间才能填充数组,所以这就是为什么我要尝试这样做,以获得更好的性能。问题是我刚刚开始涉及多线程,我有很多阅读要做。在阅读了几篇有关此事的帖子后,我也尝试解决了我的问题,其中一个是How to store assets with asynchronous enumerator in ALAssetsLibrary?,但这都是徒劳的。

    void (^assetEnumerator)(ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop)
    {
       if (result != NULL) {

           dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

            ALAssetRepresentation *rep = [result defaultRepresentation];
            CGImageRef ref = [rep fullScreenImage];
            UIImage *image = [UIImage imageWithCGImage:ref];
            NSLog(@"%@",image);  ->>> the image exists

               dispatch_async(dispatch_get_main_queue(), ^ {
                NSLog(@"%@ This is my array",_albumPics);
               [_albumPics addObject:image];
            });

         });
      }

  };

我还尝试通过资产数组中的经典迭代来获取没有块的图像....快速解决这个问题真的很棒!非常感谢

2013-04-05 16:31:42.256 Photo_Share [10276:907]( )这是我的数组

0 个答案:

没有答案