So I have been searching everywhere, but can't come to an answer on this. I have a UISearchBar searchBar setup that filters my data. I came across scope functionality, but created my own scope buttons. So my question is, how do I link those buttons I made so that they can perform the same thing as UISearchBar scopes?
The scope buttons are more a convenience than anything else. They don't automatically change the scope of the search. That is something you have to do in response to the user changing the scope.
Normally, you don't make the buttons yourself. You set the titles for the buttons in the scopeButtonTitles
property of the search bar, e.g.:
self.searchController.searchBar.scopeButtonTitles = ["Scope 1", "Scope 2"]
and then in the UISearchBarDelegate
delegate implement
func searchBar(_ searchBar: UISearchBar, selectedScopeButtonIndexDidChange selectedScope: Int)
to act upon the user's choice.
But if there's a great reason to make your own buttons, you just do it all yourself.