I found the answers, so for others here is how to do it.
First you need an instance of NSTextFinder so you can control it. We set this in code.
textFinder = [[NSTextFinder alloc] init]; [textFinder setClient:textView]; [textFinder setFindBarContainer:[textView enclosingScrollView]]; [textView setUsesFindBar:YES]; [textView setIncrementalSearchingEnabled:YES];
First answer . To clear visual feedback, I can do one of two things. I can just cancel the visual feedback ...
[textFinder cancelFindIndicator]
Or I can warn NSTextFinder that I am going to change my textView content ...
[textFinder noteClientStringWillChange]
Second answer : there is a global NSFindPboard. You can use this to search.
There is a problem though. The actual text field in the search bar is not updated after this code. I found that if I switch the first responder, I can update it ...
[myWindow makeFirstResponder:outlineView]; [myWindow makeFirstResponder:textView];
source share