Multiple NSURLConnection's in one app confusing eachother

137 views Asked by At

I have an app that uses 2 NSURLConnections to download information from a web server. They are each in completely different classes (class1 and class2). But for some reason after the one in class1 runs, and then I submit the other one in class2, instead of performing the request with the information provided in class2, it doesn't even submit a request and just automatically inherits the request from class1. So i'm just pulling in data from class1 into class2, which I do not want to do. Why can't I run this request from class2 without the class1 request interfering? Are you not able to use more than one NSURLConnection in an app?

NSMutableURLRequest *req1 = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:submissionString]];


        [NSURLConnection connectionWithRequest:req1 delegate:self];
    }

}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    if (!_responseData1) {
        [self setResponseData1:[NSMutableData data]];
    }

    [_responseData1 appendData:data];
}


- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)URLresponse {

    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)URLresponse;

    if (![httpResponse isKindOfClass:[NSHTTPURLResponse class]]) {
        NSLog(@"Unknown response type: %@", URLresponse);
        return;
    }
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection {

    res1=[[NSString alloc] initWithData:_responseData1 encoding:NSUTF8StringEncoding];
0

There are 0 answers