iphone - connectionDidFinishLoading being called before connectionDidReceiveData has received all data? -


im having problem connectiondidfinishloading being notified before connectiondidreceivedata has received , processed data. problem ocurring because trying process data arrives , update tableview. think processing slowing things down , result before have processed data connectiondidfinishloading called , seem missing out on last 10-15% of data result.

per apple docs states delegate not receive more calls after connectiondidfinishloading called. possible connectiondidreceivedata not being sent data because taking long time processing piece of data , connectiondidfinishloading called , subsequently connectiondidreceivedata isnt called again final pieces of data?

fyi tried running data processing method in own thread doesnt seem help. btw had implemented same method in connectiondidfinishloading worked fine trying start processing data instead of waiting data load take while.

here outline of code although have removed processing code little long , messy.

-(void)connection:(nsurlconnection *)connection didreceivedata:(nsdata *)newdata {  if (!self.data) {     self.data = [[[nsmutabledata alloc] init] autorelease];     nslog(@"data null"); } else {     [self.data appenddata:newdata];     [self processsearchresultsfordata:self.data]; } 

here method processes data

-(void)processsearchresultsfordata:(nsmutabledata*)newdata {  nsstring *newhtmltext = [[nsstring alloc] initwithbytes:newdata.bytes length:newdata.length encoding:nsisolatin1stringencoding];  // process new data , create array newresults results           // update results array new data if results found if ([newresults count] > 0) {            self.resultsarray = newresults;     [self updatetablewithresults];  } } 

this method updates tableview

-(void)updatetablewithresults {     // lot more processing here         // set results array table data source     [self.tableview reloaddata];             } 

thx


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -