Every time I call the changeImage function the img image will change. The problem is that the RAM memory used by the app will increase every time the photo is changed, even if the previous photo is no longer on the screen.
enter code here import UIKit
class ViewController: UIViewController {
var takenImage = UIImage()
@IBOutlet var img: UIImageView!
@IBOutlet var buton: UIButton!
var index = 0
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func changeImage(_ sender: Any) {
index+=1
switch(index) {
case 1: img.image = UIImage(named: "i1")
case 2: img.image = UIImage(named: "i2")
case 3: img.image = UIImage(named: "i3")
case 4: img.image = UIImage(named: "i4")
case 5: img.image = UIImage(named: "i5")
case 6: img.image = UIImage(named: "i6")
default: print("default");
}
}
}
I expect to delete the old photos from the RAM memory