I'm trying to grab all of the users PHAsset
with PHAssetMediaTypeImage
and then iterate through them, getting the corresponding UIImages
one at a time. I have about 2k photos on my iPhone 5 and this code crashes after iterating through 587 of them.
PHFetchResult *fr = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:nil];
PHImageManager *manager = [PHImageManager defaultManager];
PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
options.synchronous = YES;
__block int i = 0;
for (PHAsset *result in fr)
{
[manager requestImageForAsset:result targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeAspectFill options:options resultHandler:^(UIImage *image, NSDictionary *info) {
NSLog(@"%d", i);
i++;
}];
}
The exception reads EXC_BAD_ACCESS (code=1, address=0x0). Any help pointing me in the right direction on this will be enormously appreciated.