> On Jun 24, 2016, at 12:17 PM, Kenny Leung via swift-users 
> <[email protected]> wrote:
> 
> 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)
>     }
> }

Glad to hear you were able to work your problem out. If you have time, we'd 
still appreciate a bug report about the unhelpful type error message.

-Joe
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to