title: Change a NSURL's scheme
body: <p>Is there an easy way to change the scheme of a <code>NSURL</code>? I do realize that <code>NSURL</code> is immutable. My goal is to change the scheme of an URL to "https" if the <code>Security.framework</code> is linked, and "http" if the framework is not linked. I do know how to detect if the framework is linked. </p>
  
  <p>This code works wonderfully if the URL has no parameters (such as "?param1=foo&amp;param2=bar"):</p>
  
  <pre><code>+(NSURL*)adjustURL:(NSURL*)inURL toSecureConnection:(BOOL)inUseSecure {
      if ( inUseSecure ) {
          return [[[NSURL alloc] initWithScheme:@"https" host:[inURL host] path:[inURL path]] autorelease];
      }
      else {
          return [[[NSURL alloc] initWithScheme:@"http" host:[inURL host] path:[inURL path]] autorelease];
      }    
  }
  </code></pre>
  
  <p>But if the URL does have parameters, <code>[inURL path]</code> drops them. </p>
  
  <p>Any suggestions short of parsing the URL string myself (which I can do but I want to try not doing)? I do what to be able to pass URLs with either http or https to this method. </p>