tags:

views:

29

answers:

1

Hello Master Mind Friends I have One issue i am showing information of web site using web view. Before showing it i want to know is it url link active or not if it is then i will show it in webView otherwise i will show alert message to User. Can anyone help to me. The url is like www.domainname.com:8150/imagename.jpg will it work or not. In this i want to know Will this link active or not. Thanks in advance.

A: 
  1. Check whether your internet connection is alive with well known host. For example you can use the following request:

NSMutableURLRequest req = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.google.com"]]; NSHTTPURLResponse urlResponse = nil; NSError *error = [[[NSError alloc] init] autorelease];
NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:&urlResponse error:&error];
[req release];

  1. Then do the same for your url.
Valentyn