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)
For Swift3 just use following:
let array = [UInt8](yourDataObject)
That's all, folks!)