Search code examples
iosuiimagepickercontrolleralassetslibraryphotolibrary

Name image before saving to photo library


I am building an app in which I want to name images before saving it to photo library. User will open camera take picture and will write some message on it and then will save it to photo library. Now when user select the picture I want to know what message was written on it. So, i thought better name that picture with the message written and adding some unique identity. But I am unable to find any source code or tutorial which shows how to name image before saving to photo library. Thanks in advance


Solution

  • You can not specify the name. Instead, you should use an API which provides you with the unique identity of the newly saved image and store that, together with the message, inside your app.

    That API is:

    ALAssetsLibrary -writeImageToSavedPhotosAlbum:metadata:completionBlock:
    

    where the completion block is provided with the unique assetURL.

    (note to take care about your images being deleted as they will be deleted from outside of your app).