title: Swift: convert const char ** output parameter to String
body: <p>I'm interacting with a C++ library (with the header in C) which uses <code>const char **</code> as an output parameter.</p>
  <p>After executing a method in that library, the value I need is written in that variable, for example:</p>
  <pre><code>CustomMethod(const char **output)
  
  CustomMethod(&amp;output)
  
  // Using the `output` here
  
  </code></pre>
  <p>Normally, in Swift it's possible to pass just a standard Swift <code>String</code>  as a parameter and it will be transparently transformed into the <code>const char *</code> (<a href="https://developer.apple.com/swift/blog/?id=6" rel="nofollow noreferrer">Interacting with C Pointers - Swift Blog</a>).</p>
  <p>For example, I already use the following construct a lot with the same library:</p>
  <pre><code>// C
  BasicMethod(const char *input)
  
  // Swift
  let string = &quot;test&quot;
  BasicMethod(string)
  </code></pre>
  <p>However, when it comes to working with <code>const char **</code>, I couldn't just pass a pointer to the Swift <code>String</code>, as I'd expected:</p>
  <pre><code>// C
  CustomMethod(const char **output)
  
  // Swift
  var output: String?
  CustomMethod(&amp;output)
  </code></pre>
  <p>Getting an error:</p>
  <blockquote>
  <p>Cannot convert value of type 'UnsafeMutablePointer&lt;String?&gt;' to
  expected argument type 'UnsafeMutablePointer&lt;UnsafePointer?&gt;'
  (aka 'UnsafeMutablePointer&lt;Optional&lt;UnsafePointer&gt;&gt;')</p>
  </blockquote>
  <p>The only way I could make it work is by manipulating the pointers directly:</p>
  <pre><code>// C
  CustomMethod(const char **output)
  
  // Swift
  var output: UnsafePointer&lt;CChar&gt;?
  CustomMethod(&amp;output)
  let stringValue = String(cString: json)
  </code></pre>
  <p><strong>Is there any way to use the automatic Swift string to <code>const char **</code> conversion, or does it only work with <code>const char *</code>?</strong></p>