Skip to content

Instantly share code, notes, and snippets.

@endodoug
Last active November 4, 2016 02:35
Show Gist options
  • Save endodoug/1545900d275c171e79c491787098c789 to your computer and use it in GitHub Desktop.
Save endodoug/1545900d275c171e79c491787098c789 to your computer and use it in GitHub Desktop.
Save Photo to Library - Swift 3
func savePhotoToLibrary(image: UIImage) {
let photoLibrary = PHPhotoLibrary.shared()
photoLibrary.performChanges({
PHAssetChangeRequest.creationRequestForAsset(from: image)
}) { (success: Bool, error: Error?) -> Void in
if success {
// Set thumbnail
self.setPhotoThumbnail(image: image)
} else {
print("Error writing to photo library: \(error!.localizedDescription)")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment