如何在Swift 3中处理UnsafePointer <uint8>

时间:2017-03-12 01:05:22

标签: swift3

我从https://github.com/jrickard/BLEBasics.git下载了此代码 并且它是用 Swift 2 编写的,当我想将它编译成 Swift 3 时,它们发生了一个错误:“模糊地使用init”

SELECT 
  autor.nombre as Autor, 
  frase.texto as frase, 
  group_concat(tema.nombre separator ", ") as temas 
FROM tema_frase 
INNER JOIN tema ON tema_frase.tema_id=tema.tema_id 
INNER JOIN frase ON frase.id=tema_frase.frase_id 
INNER JOIN autor ON autor.id=frase.autor_id
GROUP BY autor.nombre, frase.texto

1 个答案:

答案 0 :(得分:1)

Data(bytes:count:)需要UnsafeRawPointer,而非UnsafePointer。您可以像这样简单地传递&notMuch

let notMuchNS = Data(bytes: &notMuch, count: MemoryLayout<Int>.size)

此外,Swift 3中没有sizeof,而是使用MemoryLayout<T>.size