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")
     }
}

Upvotes: 1

Views: 367

Answers (1)

Sohel L.
Sohel L.

Reputation: 9540

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)
}

Upvotes: 3

Related Questions