title: How to prepend url with http:// using stringWithFormat in Swift
body: <p>I'm building a custom browser using UIWebView.</p>
  
  <p>Use case: User enters "www.abc.com" into the address bar. Error below thrown:</p>
  
  <pre>Error Domain=WebKitErrorDomain Code=102 "Frame load interrupted" UserInfo=0x19860770 {NSErrorFailingURLKey=file://www.abc.com, NSErrorFailingURLStringKey=file://www.abc.com, NSLocalizedDescription=Frame load interrupted}</pre>
  
  <p>Reason: the URL needs to be prepended with "http://"</p>
  
  <p>I would like to use the <code>stringWithFormat</code> method of NSString, but I can't seem to get the syntax correct. In Objective-C, we have;</p>
  
  <pre><code>NSString* modifiedURLString = [NSString stringWithFormat:@"http://%@", urlString];
  </code></pre>
  
  <p>In Swift, the method is not there?!</p>
  
  <pre><code>var modifiedURLString: String = String(`stringWithFormat not here?!...`)
  </code></pre>
  
  <p>I then tried mixing Objective C with Swift:</p>
  
  <p>var modifiedURLString: NSString = [NSString <code>stringWithFormat not here?!...</code></p>
  
  <p>Then I tried straight-up Objective-C:</p>
  
  <p>NSString* modifiedURLString = [NSString stringWithFormat:@"http://", urlString];</p>
  
  <p>Thank you for your help. Sincerely, Keith</p>