[swift-users] Problems - hard to describe
    Kenny Leung 
    kenny_leung at pobox.com
       
    Fri Jun 24 14:17:11 CDT 2016
    
    
  
Hi All.
I fixed my Problems. It turns out I had the declaration typed wrong. CType should have been CChar instead of [CChar]. The working version is this:
public struct ArrayBridge<SwiftType,CType> {
    let originals  :[SwiftType]
    let translated :[[CType]]
    let pointers   :[UnsafePointer<CType>?]
    public let pointer    :UnsafePointer<UnsafePointer<CType>?>
    init(array :[SwiftType], transform: @noescape (SwiftType) throws -> [CType]) throws {
        self.originals = array
        self.translated = try array.map(transform)
        var pointers = [UnsafePointer<CType>?]()
        for item in translated {
            pointers.append(UnsafePointer<CType>(item))
        }
        pointers.append(nil)
        self.pointers = pointers
        self.pointer = UnsafePointer(self.pointers)
    }
}
-Kenny
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160624/3a8f61d8/attachment.html>
    
    
More information about the swift-users
mailing list