Saving image and then loading it in Swift (iOS)
This function will save an image in the documents folder: func saveImage(image: UIImage) -> Bool { guard let data = UIImageJPEGRepresentation(image, 1) ?? UIImagePNGRepresentation(image) else { return false } guard let directory = try? FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false) as NSURL else { return false } do { try data.write(to: directory.appendingPathComponent(“fileName.png”)!) return … Read more