I have a 'canvas' view in which the user can enter a short strings at various positions. I use an NSTextField for the entry, or for editing, but when not being edited the text is just drawn in the view's draw method.
Currently, I create a new NSTextField whenever entry or editing is needed, and don't retain it, so when it is removed as a subview, it is presumably deallocated.
This works fine, and typing being slower than the processor, there is no evident delay.
Recently I found a need to go to the 'finish editing' method from a different part of the program, so the sender is no longer necessarily the NStextField; I added a property for the the text field being used for this purpose, and now set it to nil when a particular editing task is finished. THis seems to still work fine.
As a matter of principle, would it be preferable to simply retain a single NSTextField, and simply add or remove it from the superview, instead of always making a new one?
Added later: I've decided to go with the single NSTextField, putting it in and out of the superview as needed. This seems 'cleaner' to me, but I'd still be interested in any opinions pro or con.