0

i have code with dynamically generated uiimage:

for product in self.productObject {
                if product.code != nil{
                    self.imageView1.image = UIImage(contentsOfFile: documentsDir.appendingPathComponent("myfiles").path + "/" + product.code! + ".jpg")
                }
            }

I need to get the path of the currently displayed image in the button:

@IBAction func showImagesInPopup(_ sender: Any) {
        var path = self.imageView1.image.path
        self.performSegue(withIdentifier: "toProductDetail", sender: self)
    }

How can I get it and save to "path"?

Tanvir Nayem
  • 702
  • 10
  • 25
trifd
  • 83
  • 1
  • 1
  • 7
  • You could make a UIImageView subclass, add a setImage(with path: String), save it inside a "path" variable and voilà – Roux Jun 25 '18 at 09:21
  • I guess that `var path` is nil (I think that's normal behavior). What about adding an extension to `UIImageView`, with a property `imagePath`, and when you set it, it sets the image too. – Larme Jun 25 '18 at 09:22
  • I think it's a good idea – trifd Jun 25 '18 at 09:24

0 Answers0