Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>i had some positive progress with the issue... using NSURLCOnnection, as rog mentioned, implemented a cancel before sending a new request. My code is as follows</p> <pre><code>- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { if([searchText length]&lt;4) return; else{ //[tableData removeAllObjects];// remove all data that belongs to previous search //make the call url=[NSString stringWithFormat:@"http://xml.customweather.com/xml?client=clinique_test&amp;client_password=f@c3$toF&amp;product=search&amp;search=%@",searchBar.text]; NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:5.0]; NSLog(@"%@",url); if(connection!=nil){ //cancel if in process NSLog(@"connection cancelled"); [connection cancel]; } connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; NSLog(@"Making request"); } } - (void)connection:(NSURLConnection *)theConnection didReceiveData:(NSData *)incrementalData { if (data==nil) { data = [[NSMutableData alloc] initWithCapacity:2048]; } [data appendData:incrementalData]; [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; } - (void)connectionDidFinishLoading:(NSURLConnection*)theConnection { NSString *res=[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"%@",res); [connection release]; connection=nil; [data release]; data=nil; [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; /* MY custom function goes here*/ } } </code></pre> <p>That worked pretty good for me - a sample console output is</p> <pre><code>2010-11-29 15:46:52.535 searchBar1[2931:207] Making request 2010-11-29 15:46:52.678 searchBar1[2931:207] connection cancelled 2010-11-29 15:46:52.690 searchBar1[2931:207] Making request 2010-11-29 15:46:52.871 searchBar1[2931:207] connection cancelled 2010-11-29 15:46:52.876 searchBar1[2931:207] Making request 2010-11-29 15:46:53.063 searchBar1[2931:207] connection cancelled 2010-11-29 15:46:53.069 searchBar1[2931:207] Making request 2010-11-29 15:46:53.367 searchBar1[2931:207] connection cancelled 2010-11-29 15:46:53.372 searchBar1[2931:207] Making request 2010-11-29 15:46:53.529 searchBar1[2931:207] connection cancelled 2010-11-29 15:46:53.535 searchBar1[2931:207] Making request 2010-11-29 15:46:54.354 searchBar1[2931:207] &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;cw_citylist size="1" search_type="city"&gt; &lt;city id="75281" name="Singapore" state="" state_name="" country="SN" country_name="Singapore" lat="1.28" long="103.84" population="2930200" timezone="8" timezone_code="SGT" timezone_id="Asia/Singapore" localtime="Mon, 29 Nov 2010 15:50:43 SGT" region="Indonesia" weather_id="75281" /&gt; &lt;/cw_citylist&gt; 2010-11-29 15:46:54.360 searchBar1[2931:207] Searching for ... city 2010-11-29 15:46:54.364 searchBar1[2931:207] Found in Singapore, Singapore 2010-11-29 15:46:54.368 searchBar1[2931:207] contacts error in num of row 2010-11-29 15:46:54.374 searchBar1[2931:207] Array value is Singapore,Singapore </code></pre> <p>If you notice the request got cancelled as i inputted characters into the searchbar.</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