Question

Most of the examples that I saw only connects NSSearchField to an NSArrayController. The problem is that I populated my NSTableView using NSTableViewDataSource protocol. I want my NSSearchField to search on the given NSTableView. Is there any way that I can do that or should I convert my datasource into an NSArray Controller?

Was it helpful?

Solution

You can use an NSSearchField without an array controller but you are responsible for handling the search and update of the table view.

Have your data source class respond to the ‑controlTextDidChange: and/or the ‑controlTextDidEndEditing: delegate methods of NSControl (NSSearchField is a subclass of NSControl) and in those delegate method do your search and update the table accordingly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top