In my iPAD application, I have 6 UITableViews. To get data for each of the tableview, I call a Webservice using NSURLConnection and parse the xml I get back from the Webservice and store data into the database.
Since I have 6 UITableView, I send the Webservice request for each of the views at the same time. However, the problem that I am facing is that, for my app to receive data from the Webservice on the
for 1 table view keeps depending upon the database operations performed by the parsers of the other tableviews.
For example, the webservice request for tableview's A, B, C, D are all sent at the same time. if I get back the data on the
function, until the xml received is parsed and saved to my database, I am not getting the response back for the other tableviews.
I am unable to figure out what I am doing wrong. I know NSURLConnection is asynchronous but the response I am getting does not seem so.
Here is my code -
For sending the Webservice request -
Would someone be able to help me what I am doing wrong?
Since I have 6 UITableView, I send the Webservice request for each of the views at the same time. However, the problem that I am facing is that, for my app to receive data from the Webservice on the
Code:
-(void) connection:(NSURLConnection *) connection didReceiveData:(NSData *) data
For example, the webservice request for tableview's A, B, C, D are all sent at the same time. if I get back the data on the
Code:
-(void) connection:(NSURLConnection *) connection didReceiveData:(NSData *) data
I am unable to figure out what I am doing wrong. I know NSURLConnection is asynchronous but the response I am getting does not seem so.
Here is my code -
For sending the Webservice request -
Code:
- (void) callMedicationWebService
{
. \\ declaring stuff needed to point to Webservice
.
.
conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
if (conn)
{
webData = [[NSMutableData data] retain];
}
}
-(void) connection:(NSURLConnection *) connection
didReceiveResponse:(NSURLResponse *) response
{
[webData setLength: 0];
}
-(void) connection:(NSURLConnection *) connection
didReceiveData:(NSData *) data
{
[webData appendData:data];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"HH:mm:ss"];
NSString *alertMessage = [formatter stringFromDate:[NSDate date]];
[formatter release];
NSLog(@"got data back from WS %@", alertMessage);
}
-(void) connectionDidFinishLoading:(NSURLConnection *) connection
{
[connection release];
// Parse xml
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:[CommonHelper decodeHTMLCharactorsFromString:webData]];
TableAHandler *handler = [[TableAHandler alloc] init];
[handler initTableAHandler];
[xmlParser setDelegate:handler];
[xmlParser setShouldResolveExternalEntities:YES];
[xmlParser setShouldProcessNamespaces:YES];
BOOL success = [xmlParser parse];
}
Would someone be able to help me what I am doing wrong?
Last edited: