I need to cancel a NSMutableRequest and a XMLParsing if the user choose another view
I do this on ViewDidLoad:
NSMutableURLRequest * req = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:endereco]
cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:20.0f];
conn = [NSURLConnection connectionWithRequest:req delegate:self];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
if(conn)
{
receivedData = [[NSMutableData alloc]init];
[DSBezelActivityView newActivityViewForView:self.view withLabel:@"Obtendo Lista..."];
}
I know i have to : [conn cancel];
on viewWillDisappear, but how i can check i the connection is ocurring so i can cancel it?
And the same happens to the parse method :
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSXMLParser * parser = [[NSXMLParser alloc]initWithData:receivedData];
[parser setDelegate:self];
[parser parse];
[parser release];
[receivedData release];
}