0

I want to call the web api when uitextfield text changed.problem is,if i type text fast ex "abcd" it call the api four times.I want to handle the api call,if i type fast then is should call the api one time with hole string.If i type slowly then its ok.normally we type fast then it call the api many times its a problem.

any one have idea for this

- (IBAction)editTextField:(id)sender {

         [self callapiwithtype_text];

}
mychar
  • 1,031
  • 1
  • 11
  • 20

1 Answers1

0

You can try creating an Operation Queue that only allows a single operation to execute at a time. When your action fires, have it cancel any executing operations, and create and execute a new operation. This way only the "last" operation will be active, and only the final request will return results.

Another option is to add a delay between the time the event fires and you call the API. If another event is received before the delay is up, don't send the request.

Robert Zahm
  • 1,877
  • 2
  • 12
  • 8