Note that there are some explanatory texts on larger screens.

plurals
  1. POconnectionDidFinishLoading being called before connectionDidReceiveData has received all data?
    primarykey
    data
    text
    <p>Im having a problem where connectionDidFinishLoading is being notified before connectionDidReceiveData has received and processed all the data. The problem is ocurring because i am trying to process the data as it arrives and update a tableview. I think this processing is slowing things down and as a result before i have processed ALL the data connectionDidFinishLoading is called and i seem to always be missing out on the last 10-15% of the data as a result.</p> <p>Per the apple docs it states that the delegate will not receive any more calls after connectionDidFinishLoading is called. Is it possible that connectionDidReceiveData is not being sent all the data because it is taking a long time processing a piece of data and then connectionDidFinishLoading is called and subsequently connectionDidReceiveData isnt called again with the final pieces of data?</p> <p>Fyi i tried running the data processing method in its own thread however that doesnt seem to help. Btw i had already implemented this same method in connectionDidFinishLoading which worked fine however i am trying to start processing data immediately instead of waiting for all the data to load which could take a while.</p> <p>Here is the outline of the code although i have removed the processing code as it is a little long and messy.</p> <pre><code>-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)newData { if (!self.data) { self.data = [[[NSMutableData alloc] init] autorelease]; NSLog(@"data is null"); } else { [self.data appendData:newData]; [self processSearchResultsForData:self.data]; } </code></pre> <p>Here is the method that processes the data</p> <pre><code>-(void)processSearchResultsForData:(NSMutableData*)newData { NSString *newHtmlText = [[NSString alloc] initWithBytes:newData.bytes length:newData.length encoding:NSISOLatin1StringEncoding]; // process new data and create an array newResults with results // only update results array with new data if results were found if ([newResults count] &gt; 0) { self.resultsArray = newResults; [self updateTableWithResults]; } } </code></pre> <p>This method updates the tableView</p> <pre><code>-(void)updateTableWithResults { // do a lot more processing here // then set results array as table data source [self.tableView reloadData]; } </code></pre> <p>thx</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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