I have a little Problem with my Code after updating to Swift 3. I had this Code before the conversion:
extension NSData {
func castToCPointer<T>() -> T {
let mem = UnsafeMutablePointer<T>.alloc(sizeof(T.Type))
self.getBytes(mem, length: sizeof(T.Type))
return mem.move()
}
}
And I converted it to this Code and in the 3rd line I get an Error
... Cannot convert value of type 'UnsafeMutablePointer' to expected argument type 'UnsafeMutablePointer'
extension Data {
func castToCPointer<T>() -> T{
let mem = UnsafeMutablePointer<T>.allocate(capacity: MemoryLayout<T.Type>.size)
self.copyBytes(to: mem, count: MemoryLayout<T.Type>.size)
//self.copyBytes(to: mem, count: MemoryLayout<T.Type>.size)
return mem.move()
}
}
Does anyone know how to get rid of this?