I'm building a MenuBar Swift Cocoa application that displays a list of user's github repositories. After clicking on one, it opens a new browser window with the repository on github.com.
I am successfully loading the list of repos and rendering them to NSMenuItem objects. Now, I'm trying to add a search bar on the top of the list and re-render the items according to the search phrase.
My questions are:
- What is the best approach to display a "search bar" in the NSMenu?
- Is there a standard way to "search/filter"
NSMenuItem
s? - Should I re-render the whole menu (calling
.removeAllItems()
) and add new items dynamically? Or should I have two static menus? I'm asking this because the layout (eg.NSMenuItem
s) is going to be difference when user is searching and when they're not.
I'm using Swift 3 and Xcode 8.3. Thanks!