Skip to content

Instantly share code, notes, and snippets.

@MemoryReload
Forked from BetterProgramming/url.swift
Created July 5, 2022 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MemoryReload/d8bac8b2d9d9d65df3e4db0e3bdf4218 to your computer and use it in GitHub Desktop.
Save MemoryReload/d8bac8b2d9d9d65df3e4db0e3bdf4218 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