Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created May 25, 2022 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save BetterProgramming/745e3d6b8b95bcaeebde97a34cd7ce53 to your computer and use it in GitHub Desktop.
Save BetterProgramming/745e3d6b8b95bcaeebde97a34cd7ce53 to your computer and use it in GitHub Desktop.
extension URL {
func loadImage(_ image: inout UIImage) {
if let loaded = UIImage(contentsOfFile: self.path) {
image = loaded
}
}
func saveImage(_ image: UIImage) {
if let data = image.jpegData(compressionQuality: 1.0) {
try? data.write(to: self)
}
}
}
https://developer.apple.com/forums/thread/661144
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment