I have tried to run the below code in swift 3
var values = [UInt8](count:data!.length, repeatedValue:0) data!.getBytes(&values, length:data!.length)
It means that the arguments order has been reversed in Swift 3.
For NSData:
var values = [UInt8](repeating:0, count:data!.length) data.getBytes(&values, length: data!.length)
For Data:
var values = [UInt8](repeating:0, count:data!.count) data.copyBytes(to: &values, count: data!.count)