Skip to content

Instantly share code, notes, and snippets.

@jayesh15111988
Created January 15, 2017 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jayesh15111988/df00d391be391adc56a2aac3764dc7b7 to your computer and use it in GitHub Desktop.
Save jayesh15111988/df00d391be391adc56a2aac3764dc7b7 to your computer and use it in GitHub Desktop.
private var searchTimer: Timer?
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
if let searchTimer = searchTimer {
searchTimer.invalidate()
}
searchTimer = Timer.scheduledTimer(timeInterval: 0.4, target: self, selector: #selector(self.reload(timer:)), userInfo: searchText, repeats: false)
}
func reload(timer: Timer) {
print(timer.userInfo ?? "")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment