Reputation: 11
I used synchronous request to fetch data from server and insert those data in the database.This is working perfectly alright.Now the problem is that I want to stop the request in between the process is going on (means when the request is already send for data or during when the data are inserting in the database).So Is there any way that we can stop the Synchronous request forcefully.What is the best way to do that?Please suggest... Below is the code for that
NSURL *url = [NSURL URLWithString:soapMessage];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest addValue: @"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[theRequest setHTTPMethod:@"GET"];
NSData *theData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse: nil error:nil];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData: theData];
[xmlParser setDelegate: self];
[xmlParser setShouldResolveExternalEntities: YES];
[xmlParser parse];
[xmlParser release];
and after that performed simple insert operation.
Upvotes: 1
Views: 861
Reputation: 9820
the only way to stop a synchronous request is to kill the thread it is on. (hence the term synchronous).
Upvotes: 1