controlTextDidChange vs textDidEndEditing

I have textFields in this OSX App.


I want to perform some test when editing ends.


used to use controlTextDidChange or controlTextDidEndEditing by conforming to NSTextFieldDelegate for the class and setting the delegate to file's owner.


That works well, but I noticed those are deprecated.


So I try to use func textDidEndEditing(_ notification: Notification) instead.

I never can get it called.

I tried to conform the class to NSControlTextEditingDelegate, without effect.


After reading some blogs as h ttp://thegreyblog.blogspot.com/2014/06/ , I suspected the problem was how I set the delegate. But could not find how to change.

I looked at Apple's doc, which is, unfortunately as usual, extremely limited. It states old methods are deprecated but do not hint at how to use new ones.


Am I missing something obvious ?

Accepted Reply

I don't think those methods are deprecated. They've just moved from being an informal protocol (a category on NSObject) to a formal protocol, NSControlTextEditingDelegate. The (non-deprecated) method is here.

Replies

I don't think those methods are deprecated. They've just moved from being an informal protocol (a category on NSObject) to a formal protocol, NSControlTextEditingDelegate. The (non-deprecated) method is here.

Thanks.


This shows that documentation may be really misleading: searching for textDidEndEditing in XCode documentation leads to

NSControl controlTextDidEndEditing

where it is marked as deprecated.

And no reference there to

NSControlTextEditingDelegate controlTextDidEndEditing(_:)