2
votes

I started to play with macOS development recently, and for last 2 days I'm struggeling with text views.

I have Scrollable TextView, which is NSScrollView (and NSTextView is it's .documentView). I need to do some actionevery time user change a text.

In iOS it's very easy. I just set UITextView's delegate. However, I can't find anything relevant in documentation, nor here, regarding to NSTextView's. No textDidChange or something.

Thanks guys, help appreciated.

1
@BenRockey The link points to textViewDidChangeTypingAttributes which is "Sent when a text view’s typing attributes change.".Willeke

1 Answers

2
votes

Just set the text view's delegate. The delegate must coform to NSTextViewDelegate. NSTextViewDelegate inherits from NSTextDelegate (see relationships and NSTextView is a subclass of NSText). NSTextDelegate defines method

optional func textDidChange(_ notification: Notification)