I have a search bar with a suggestions UITableView that gets populated (using JSON services) as the user types. These service calls need to be made after a delay of 500ms of non-typing. If the user starts to type in this period of 500ms, the current call in the queue needs to be cancelled and the app has to wait another 500ms of non-activity before making another afterDelay call. I know I have to use performSelector:withObject:afterDelay in this entire situation, but I’m not able to get around with proper conditions. I tried using a bunch of bools but it just getting dirty… Any help?
I have a search bar with a suggestions UITableView that gets populated (using JSON
Share
I would use an
NSTimerinstead ofperformSelector:withObject:afterDelay:. Detect when the text changes in theUISearchBarand reset the timer.