只是想知道下面的这段代码......当我关闭我的互联网连接并运行它时,我预计我会在我的控制台日志中得到“连接失败”。谁能解释为什么我不是?谢谢。
NSString *urlString = [NSString stringWithFormat:@"http://www.myurl.com/RSS/feed.xml"];
NSURL *serviceURL = [NSURL URLWithString:urlString];
//Create the request
NSURLRequest *request = [NSURLRequest requestWithURL:serviceURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30];
//Create the connection and send the request
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
//Make sure the connection is good
if (connection) {
//instantiate the responseData structure to store the response
self.responseData = [NSMutableData data];
}
else {
NSLog(@"Connection failed");
}