Skip to content

Instantly share code, notes, and snippets.

@PetreVane
Created October 1, 2019 17:19
Show Gist options
  • Save PetreVane/e75012d3b0123c1fe32e78439c924305 to your computer and use it in GitHub Desktop.
Save PetreVane/e75012d3b0123c1fe32e78439c924305 to your computer and use it in GitHub Desktop.
func fetchImageWithFileManager(image: String) -> UIImage? {
if let pathUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] {
let dirURL = pathUrl.appendingPathComponent(image)
do {
let imageData = try Data(contentsOf: dirURL)
return UIImage(data: imageData)
} catch {
print("Failed loading image")
}
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment