我试图寻找答案,但没有找到适合我的解决方案。
我正在尝试做的就是正确设置我的NSURLConnection。当我调用doSomethingTwo()时,我从didReceiveResponse和didReceiveData获得打印输出,但不是didFailWithError或connectionDidFinishLoading。还有什么我需要做的,我错过了吗?
这是我的代码:
- (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);
}
答案 0 :(得分:3)
您没有将connectionDidFinishLoading
中的“L”大写。