So, I have a tableView
with NSFetchedResultsController
! I have also a UISearchController
, and works perfectly! But I need a Scope Bars to the UISearchBar
. How to create and how to add a Scope Bars in Swift Core Data?
Thanks!
Just give the search bar scopeButtonTitles
at the time you obtain it from the UISearchController. As you present the search controller, set the search results controller as the search bar's delegate, so it will get searchBar:selectedScopeButtonIndexDidChange:
when the user changes scope buttons, and there you just call updateSearchResultsForSearchController
and deal with the search as you're already doing — taking account, now, of what the current scope button index is.