Note that there are some explanatory texts on larger screens.

plurals
  1. POCall webservice when each key is pressed in iphone
    text
    copied!<p>I am using a search bar and whenever i enter a text in the search bar it should take that string and it will form a request string and produce the output.To be more clear assume like if i press 'c' i want to display city names staring with c and after that with the 'c' still present in the search bar i press 'h',so now the string is 'ch' so using the webservice i am searching for citiy names that start with 'ch'.I use a JSON kind of webservice and the response is populated on the table view</p> <p>My problem is when i press the keys slowly the searching is done properly,but when the keys are pressed fastly that is when i press 'c' and then swiftly i have pressed 'h'.The webservice is accessed for 'ch' then 'c'..This makes to print the cities starting with c instead of CH..</p> <p>I am calling the web service on each key press in the following way:</p> <p>statement to call the webservice inside the </p> <pre><code>- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchString { .... ... [NSThread detachNewThreadSelector: @selector(callService) toTarget:self withObject:nil]; } and inside the callService method..... - (void)callService{ NSAutoreleasePool *pool = [ [ NSAutoreleasePool alloc ] init ]; [self performSelectorOnMainThread:@selector(initializeRequest) withObject:nil waitUntilDone:NO]; [pool release]; } - (void)initializeRequest { ....Here i form the request string... create connection and after creating connection i use NSURLConnectionDelegate Methods to parse the connection } </code></pre> <p>Is there is any way to do the searching on the fly smoothly.</p> <p>Please any body suggest me any other alternative or approach to perform this kind of search on the fly when the text gets changed in the search bar.Thank you one and all </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload