Website Timeout Test
Hello All !
I am trying to implement some code to check for a timeout of a website request. I am using the following code to check for a website. I have only run this in the simulator and regardless of if I have my Internet connection turned off or if I block the site with a program such as little snitch it always returns YES. Any Ideas where I am going wrong?
[CODE]
-(BOOL) canConnect;
{
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection)
{
NSLog(@"SUCCESS");
return YES;
} else {
// inform the user that the download could not be made
NSLog(@"ERROR");
return NO;
}
}
[/CODE]
Thanks !
I am trying to implement some code to check for a timeout of a website request. I am using the following code to check for a website. I have only run this in the simulator and regardless of if I have my Internet connection turned off or if I block the site with a program such as little snitch it always returns YES. Any Ideas where I am going wrong?
[CODE]
-(BOOL) canConnect;
{
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection)
{
NSLog(@"SUCCESS");
return YES;
} else {
// inform the user that the download could not be made
NSLog(@"ERROR");
return NO;
}
}
[/CODE]
Thanks !
Macbook Pro 15 Unibody, Mac OS X (10.5.6)