title: UIWebView How to get correct URL?
body: <p>I am making a simple web browser by using UIWebView. User enters an address on the address bar -> check it.</p>
  
  <p>1.If the text is url -> load the request</p>
  
  <p>2.If the text is string -> perform a google search</p>
  
  <p>In the first case, if string has the format: abc.xyz, how to add a scheme and host to it?
  Example: user enters google.com -> correct to <a href="https://google.com" rel="nofollow">https://google.com</a>
  engadget.com -> <a href="https://www.engadget.com" rel="nofollow">https://www.engadget.com</a>.</p>
  
  <p>My problem is how to know which part had to add to url(http, https, with or without www).</p>
  
  <p><strong>Update:</strong></p>
  
  <p>use NSURLSeassion to test connect</p>
  
  <pre><code>- (void)checkRequest:(NSString*)urlRequest
  {
      NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlRequest]];
      [request setHTTPMethod:@"HEAD"];
  
      NSURLSessionTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
          if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
              NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
              if (statusCode == 200)
                  NSLog(@"Correct url");
              // check status code here
          }
          if (error) {
              // handle other errors here
          }
          // handle data here
      }];
      [task resume];
  }
  </code></pre>
  
  <p><strong>Update 2</strong></p>
  
  <p>Don't need to check url, add http:// scheme and website will automatically redirect to the correct destination.</p>