I am using UIImageView
In my UIViewController
. In my case, I want to do if my image view changes then let me know if it was changed or not.
Use KVO.
class ViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
private var imageChangeObservation: NSKeyValueObservation?
override func viewDidLoad() {
super.viewDidLoad()
imageChangeObservation = imageView.observe(\.image, options: [.new]) { [weak self] (object, change) in
print("Image changed")
}
}
}