[swift-users] How to get UnsafePointer or UnsafeMutablePointer from ContiguousArray?

Sergey Kuratov ksubox.swift at gmail.com
Thu Feb 11 01:09:59 CST 2016


I got some problem with ContiguousArray<->C interaction - I can't
get address of array buffer to process in native code.

Could somebody help me to get?

Actually I also didn't find init(Array<...>) in UnsafePointer interface.

I wonder what initialiser is used when UnsafePointer<T>(Array<T>)?

Here is sample code:

class Test {

var a = 0


var testarr1 : Array<Test> = [ Test(), Test() ]

var testarr2 : ContiguousArray<Test> = [ Test(), Test() ]

let arrPtr1 = UnsafePointer<Test>(testarr1)

let arrPtr2 = UnsafePointer<Test>(testarr2) <- error "Cannot invoke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160211/5f066a49/attachment.html>

More information about the swift-users mailing list