I'm trying to save a big batch of photos into the Photos library using the new PHAssetChangeRequest
class in iOS 8. Problem is, it looks like the daemon that saves the photos is itself crashing unexpectedly with a moderately large number of photos (I'm trying about 500). Anyone have any idea how to get around this limitation? Is it a memory usage problem in the daemon itself? It could also be a timeout limit on the change block, because in between the first 2 log statements below there's a not insignificant gap.
Shouldn't the assetsd
daemon already be accounting for this use case since something like this is pretty much what the super complex model and design in the new Photos framework should have been able to handle? The documentation sample itself shows off the ability to save a photo.
Here's my code sample:
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
for (NSURL * url in fileURLs) {
PHAssetChangeRequest * assetReq = [PHAssetChangeRequest creationRequestForAssetFromImageAtFileURL:url];
}
NSLog(@"Added %d assets",fileURLs.count);
} completionHandler:^(BOOL success, NSError *error) {
if (!success){
NSLog(@"%@",error);
}
}];
And this is what my output looks like:
... Added 501 assets
... Connection to assetsd was interrupted or assetsd died
... Error Domain=NSCocoaErrorDomain Code=-1 "The operation couldn’t be completed. (Cocoa error -1.)
I even tried the synchronous performChangesAndWait
method in PHPhotoLibrary
but it also has the same problem.
I'm open to suggestions / ideas, am stuck! :(