连接我用这个代码:用的NSURLRequest
NSString *recievedData;
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.site.com/"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
// create the connection with the request
// and start loading the data
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
// Create the NSMutableData to hold the received data.
// receivedData is an instance variable declared elsewhere.
recievedData = [NSMutableData data];
NSLog(@"%@", recievedData);
} else {
// Inform the user that the connection failed.
NSLog(@"Unsuccessful.");
}
它是this修改后的版本。
我的问题是,它总是返回
<>
无论我是连接到互联网或没有,它总是转到成功。