swiftphphotolibrary

How can i save a video to the camera roll with a specific date?


I save the video to the end of the camera roll

PHPhotoLibrary.shared().performChanges({
    PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: mergedVideoFile!)
}) { saved, error in
     if saved {
         print("saved")
     }
}

Solution

  • It's quite easy, you need to pass the Date while saving the PHAsset.

    PHPhotoLibrary.shared().performChanges({
        let changeRequest = PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: videoUrl)
        changeRequest.creationDate = Date() //Pass whichever Date you want
    }) { (success, error) in
        debugPrint(success)
        debugPrint(error)
    }