I have list of selected images from Photos gallery. The array list contain selected PHAssets from Photos
<PHAsset: 0x131334350> 768AD8BA-FE7A-4EE9-B2CF-4DD4AEBE2AE9/L0/001 mediaType=1/0, sourceType=1, (2448x3264), creationDate=2016-03-11 06:50:09 +0000, location=1, hidden=0, favorite=0 ",
"<PHAsset: 0x131334260> CA962E42-A367-4E8D-85C8-934F8C76FE78/L0/001 mediaType=1/0, sourceType=1, (2448x3264), creationDate=2016-03-11 06:50:08 +0000, location=1, hidden=0, favorite=0 "
Now i want to store this images into Document Directory.For that i am converting PHAssets to original image and store it in array, for that code i did
@property (nonatomic, strong) PHImageRequestOptions *requestOptions;
for (PHAsset *asset in assetArray) {
self.requestOptions = [[PHImageRequestOptions alloc] init];
self.requestOptions.resizeMode = PHImageRequestOptionsResizeModeExact;
self.requestOptions.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
// this one is key
self.requestOptions.synchronous = true;
PHImageManager *manager = [PHImageManager defaultManager];
__block UIImage *ima;
// Do something with the asset
[manager requestImageForAsset:asset
targetSize:PHImageManagerMaximumSize
contentMode:PHImageContentModeDefault
options:self.requestOptions
resultHandler:^void(UIImage *image, NSDictionary *info) {
ima = image;
[Albumimages addObject:ima];
}];
}
But problem is that when i selected multiple images with large size(more than 25) app is crash down. Because when i convert PHAsset to original image by using PHImageManager it uses high memory of device. Please help me to solve this problem. Provide me if there is any other solution to handle selected PHAssets for storing images in application document directory.