void UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo);
but if you try to save multiple files at once
for (int i=1; i<=10; ++i) { UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil); }
you'll have every second/third file saved or even nothing will be saved. To investigate what's wrong it's required to set complete selector to UIImageWriteToSavedPhotosAlbum:
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo;
looks like this:
for (int i=1; i<=10; ++i) { UIImageWriteToSavedPhotosAlbum(image, self, @selector(savedPhotoImage:didFinishSavingWithError:contextInfo:), nil); } - (void) savedPhotoImage:(UIImage*)image didFinishSavingWithError:(NSError *)error contextInfo: (void *)contextInfo { NSLog(@"%@", [error localizedDescription]); }
and then you'll see an error description "write busy" at the log. System just unable to copy files so fast. Yes, you use just a mobile device with limited, but miraculous abilities ;) It isn't 12 Core Mac Pro.
The solution is to copy photos one by one:
- create an array of image names, e.g. wallpapers
- copy one
- catch complete selector
- goto #2




