HomeiOS Developmentios - Saving a URL to digital camera roll

ios – Saving a URL to digital camera roll


To avoid wasting a URL to the digital camera roll in Swift, you need to use the Images framework, which supplies a approach to work together with the consumer’s picture library
import Images

func saveURLToCameraRoll(url: URL, completion: @escaping (Error?) -> Void) {
    PHPhotoLibrary.shared().performChanges({
        let request = PHAssetCreationRequest.forAsset()
        let choices = PHAssetResourceCreationOptions()
        choices.originalFilename = url.lastPathComponent
        request.addResource(with: .picture, fileURL: url, choices: choices)
    }) { success, error in
        if success {
            completion(nil)
        } else {
            completion(error)
        }
    }
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments