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 !

Macbook Pro 15 Unibody, Mac OS X (10.5.6)

Posted on May 9, 2009 8:15 PM

Reply
2 replies

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Website Timeout Test

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.