I recommend you to work with Data
rather than NSData
in Swift 3.
var keyData = Data(count: 64)
let result = keyData.withUnsafeMutableBytes {mutableBytes in
SecRandomCopyBytes(kSecRandomDefault, keyData.count, mutableBytes)
}
withUnsafeMutableBytes(_:)
is declared as a generic method, so, in simple cases such as this, you can use it without specifying element type.