I have an unsigned char array in .h file. and, also I have a function that takes unsigned char array as input. When I try to call this function in swift, it gets UnsafeMutablePointer<UInt8>. So, automatic objective-c to swift converter thinks unsigned char should be converted as UnsafeMutablePointer<UInt8>. But, I can not pass my variable to this function directly. Because I get,
Cannot convert value of type '(UInt8, UInt8, UInt8, UInt8, UInt8)' to expected argument type 'UnsafeMutablePointer<UInt8>!'
Length of this array is static. So, I can create
let key = UnsafeMutablePointer<UInt8>.allocate(capacity: 64);
and, also I can get value by KEY.0, KEY.1 ... etc. So, all I need is to create a for loop to read value from KEY and assign it to key
for index in 1...64 {
key[index] = KEY[index];
}
but, this gives compilation error as:
Value of tuple type '(UInt8, UInt8, UInt8, UInt8, UInt8)' has no member 'index'
so, first question, how I can get any value from KEY by index. Second is, is there any easier way to convert a unsigned char array to UnsafeMutablePointer<UInt8>