cocoa-touchuiimagepickercontrolleriphone-sdk-3.1

UIImageWriteToSavedPhotosAlbum working... sometimes


UIImageWriteToSavedPhotosAlbum is only working sometimes. Sometimes it works, sometimes it doesn't, exact same function.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
NSLog(@"Saving image to camera roll...");
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
NSLog(@"Done!"); }

I am using a UIImagePicker controller to get the image that then calls that function.

Sometimes it saves it to the camera roll, other times it simply doesn't.

Anyone has any idea?

Thanks in advance.

Edit:

The completion method for UIImageWriteToSavedPhotosAlbum sometime returns an error of:

wait_fences: failed to receive reply: 10004003

Solution

  • I would start by adding a completion target method to the save call to see if it is producing any errors. See the UIImageWriteToSavedPhotosAlbum documentation for details.

    Edit:

    One of the times it returned... wait_fences: failed to receive reply: 10004003

    That means the operation timed out. There are many causes of this:

    1. Low memory: put a log in didReceiveMemoryWarning to see if this is the cause.
    2. Corrupt files that the system can't save. If the image is generated each time it might not come out right each time.
    3. Improperly reported disk full error.

    I think (1) most likely and explains the intermittent nature. When you have enough memory the method works and when you don't it fails.

    In addition, when you compile, resolve any warnings that come up. Those are just errors that won't show up until runtime. You're problem might be listed there