I am failing to reset/substitute the search query string programmatically. I was trying to modify the UISearchBar query string from within the UISearchControllerDelegate.
I am using dictation input.
When the command "delete" is said, the searchController.searchBar.text
should be set back to @""
. The speech detection should continue as normal with the empty string.
The query string does get reset to @""
, but the speech detection stops.
How can I reset search query string in UISearchController programmatically and still be able to continue the input using speech?
- (void)updateSearchResultsForSearchController:(nonnull UISearchController *)searchController {
NSString *searchQuery = self.searchController.searchBar.text;
// Deletion command
if ([self.searchController.searchBar.text hasSuffix:@"delete"]) {
// Things that I've tried that don't work
//[self.searchController.searchBar setText:@""];
//self.searchController = [self.searchController init];
//self.searchController.searchBar.text = @"";
searchQuery = @"";
}
}