My app allows users to attach tags to certain model objects (subclasses of NSManagedObject). The Tag class is also a subclass of NSManagedObject. I decided to use NSTokenField
to display the tags, where each token holds an instance of Tag as the represented object. It all works pretty good but I'm stuck in situations where the user deletes a token as I want to check whether the associated Tag has become obsolete and should be deleted.
I was expecting a method in NSTokenFieldDelegate
or NSTokenFieldCellDelegate
which would allow me to intercept and check a delete action on a token.
After some googling I found this post addressing the topic. I implemented the suggested method controlTextDidChange:
in my controller (the delegate of the token field). Upon inspecting the control that is passed as an argument, it revealed to be an instance of NSTokenTextView
for which I cannot find any documentation (probably a private class).
Has anybody run into this and found a solution to gracefully delete tokens while maintaining the underlying model of represented objects?
EDIT
I found this as well, which seems to suggest that for some reason it just is not designed to work like the rest of us would expect.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…