I have issues with string replacement when there are newlines.
How to properly replace string or part of a string so that bindings are triggered.
I have used open func replaceCharacters(in range: NSRange, with string: String)
but it doesn’t trigger bindings.
When I use func insertText(_ string: Any, replacementRange: NSRange)
I have to do the NSString
dancing
let textView = NSTextView()
textView.string = "LongString with newlinesrnGuten Tag!"
textView.string.count //prints 35
(textView.string as NSString).length //prints 36
textView.insertText("XX", replacementRange: NSMakeRange(0, (textView.string as NSString).length)
I feel I am fighting the framework. What is the correct way? Mind that textView.string = "XX"
doesn’t trigger bindings