I was trying to implement property observers on my custom UIViewController but I noticed it was not working with the isEditing property.
Do you guys have an idea why?
class MasterViewController: UIViewController {
// MARK: - Properties
override var isEditing: Bool {
didSet {
print("VC is editing")
}
}
}
According to the documentation for isEditing
Use the setEditing(_:animated:) method as an action method to animate the transition of this state if the view is already displayed.
And from setEditing(_:animated:)
Subclasses that use an edit-done button must override this method to change their view to an editable state if isEditing is true and a non-editable state if it is false. This method should invoke super’s implementation before updating its view.
TL;DR
You'll want to override setEditing(_:animated:)
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With