<div dir="ltr">You want testarr2.withUnsafeMutableBufferPointer().<br><div><br></div><div>-david</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 10, 2016 at 11:09 PM, Sergey Kuratov via swift-users <span dir="ltr">&lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo"><font color="#000000">Hello!</font></p><p style="margin:0px;line-height:normal"><font color="#000000"><font style="font-family:Menlo;font-size:12px">I got some problem with </font><font face="Menlo"><span style="font-size:12px">ContiguousArray&lt;-&gt;C interaction - I can&#39;t get address of array buffer to process in native code.</span></font></font></p><p style="margin:0px;line-height:normal"><font face="Menlo" color="#000000"><span style="font-size:12px">Could somebody help me to get?</span></font></p><p style="margin:0px;line-height:normal"><font face="Menlo" color="#000000"><span style="font-size:12px"><br></span></font></p><p style="margin:0px;line-height:normal"><font color="#000000"><font face="Menlo"><span style="font-size:12px">Actually I also didn&#39;t find init(</span></font><span style="font-family:Menlo;font-size:12px">Array&lt;...&gt;) in UnsafePointer interface.</span></font></p><p style="margin:0px;line-height:normal"><font color="#000000"><font face="Menlo"><span style="font-size:12px">I wonder what initialiser is used when </span></font><span style="font-family:Menlo;font-size:12px">UnsafePointer</span><span style="font-family:Menlo;font-size:12px">&lt;</span><span style="font-family:Menlo;font-size:12px">T</span><span style="font-family:Menlo;font-size:12px">&gt;(Array&lt;T&gt;)? </span></font></p><p style="margin:0px;line-height:normal"><font color="#000000"><span style="font-family:Menlo;font-size:12px"><br></span></font></p><p style="margin:0px;line-height:normal"><font color="#000000"><span style="font-family:Menlo;font-size:12px">Here is sample code:</span></font></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)"><br></span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">class</span> Test {<br></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo"><span style="white-space:pre-wrap">        </span><span style="color:rgb(187,44,162)">var</span> a = <span style="color:rgb(39,42,216)">0</span></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo">}</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">var</span> testarr1 : <span style="color:rgb(112,61,170)">Array</span>&lt;<span style="color:rgb(79,129,135)">Test</span>&gt; = [ <span style="color:rgb(79,129,135)">Test</span>(), <span style="color:rgb(79,129,135)">Test</span>() ]</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">var</span> testarr2 : <span style="color:rgb(112,61,170)">ContiguousArray</span>&lt;<span style="color:rgb(79,129,135)">Test</span>&gt; = [ <span style="color:rgb(79,129,135)">Test</span>(), <span style="color:rgb(79,129,135)">Test</span>() ]</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">let</span> arrPtr1 = <span style="color:rgb(112,61,170)">UnsafePointer</span>&lt;<span style="color:rgb(79,129,135)">Test</span>&gt;(<span style="color:rgb(79,129,135)">testarr1</span>)</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">let</span> arrPtr2 = <span style="color:rgb(112,61,170)">UnsafePointer</span>&lt;<span style="color:rgb(79,129,135)">Test</span>&gt;(<span style="color:rgb(79,129,135)">testarr2</span>) &lt;- error &quot;Cannot invoke initialiser...&quot;</p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Menlo"><br></p></div>
<br>_______________________________________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div>