I have an NSTextField in an NSView that is controlled by an NSViewController. At some point, I remove this view. When the view is removed, if the text field has focus, it will dispatch an action. Because I’m in the middle of deconstructing the data and the view, it causes a fatal exception.
I think the answer to this would be to listen for when the view is being removed from the superview in the NSViewController and then remove the view controller as the target for the action. Is there some easy way to do this that I’m missing?
I think the easiest way is to override the willRemoveSubview:(UIView *)subview method of your NSView. You should be able to do whatever you want in your implementation to prepare yourself for the removal that is about to happen.