我有一段Objective-C代码,而且我打破了如何在Swift中编写这个代码:
NSData *data = [NSData data];
char vals[value.length];
[value getBytes:vals length:value.length];
Point3D aPoint;
aPoint.x = ((float)((int16_t)((vals[0] & 0xff) | (((int16_t)vals[1] << 8) & 0xff00)))/ (float) 32768) * 255 * 1;
aPoint.y = ((float)((int16_t)((vals[2] & 0xff) | (((int16_t)vals[3] << 8) & 0xff00)))/ (float) 32768) * 255 * 1;
aPoint.z = ((float)((int16_t)((vals[4] & 0xff) | (((int16_t)vals[5] << 8) & 0xff00)))/ (float) 32768) * 255 * 1;
我尝试过使用它:
let data: NSData = NSData(data: characteristic.value!)
var vals = [CChar16](repeating: CChar16(), count: data.length)
但这只会导致:
无法下标类型&#39; inout [CChar16]&#39; (又名&#39; inout 阵列&#39)
任何帮助将不胜感激。