Reputation: 60
I've tried to search around for an answer but haven't found a solution that worked for me.
All I'm trying to do is set up my NSURLConnection correctly. When I invoke doSomethingTwo(), I get printouts from didReceiveResponse and didReceiveData, but not didFailWithError or connectionDidFinishLoading. Is there something else I need to do that I'm missing?
Here is my code:
- (void) doSomethingTwo: (CCMenuItem *) menuItem
{
NSLog(@"The second menu was called");
self.responseData = [NSMutableData data];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://theholyroller.net/iphone/index.php"]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
}
- (void) connection:(NSURLConnection *) connection didReceiveResponse:(NSURLResponse *) response {
NSLog(@"Received Response");
[self.responseData setLength:0];
}
- (void) connection:(NSURLConnection *) connection didReceiveData:(NSData *)data {
NSLog(@"Received Data");
NSLog(@"%@", data);
[self.responseData appendData:data];
}
- (void) connection:(NSURLConnection *) connection didFailWithError:(NSError *)error {
NSLog(@"Failed with error");
}
- (void) connectionDidFinishloading:(NSURLConnection *)connection {
NSLog(@"Finished Loading");
NSLog(@"%@", self.responseData);
}
Upvotes: 0
Views: 1079