我尝试阅读和CoreBluetoothCoreBluetooth阅读的NSData
所以我的设备(外设)写的东西给我一个阵列 的lenght和阵列为一体。
我用这种方法
(void)readValueForCharacteristic:(CBCharacteristic *)characteristic;
读取数值时,我从周围的
(void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error;
呼吁 当我读到一个值得到的答复是没有问题的
char arrayLength;
charakteristik.value getBytes:&arrayLength lenght:SERVICE_ARRAYLENGTH_LEN]
self.MyArrayLenght=(float)arrayLength;
-
但是,当我得到的数组从外围我不知道如何读他们
charakteristik.value是NSData的
当我试图
NSArray *array = [NSKeyedUnarchiver unarchiveObjectWithData:charakteristik.value]
我有错误
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '[NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive (0x4e, 0x49, 0x42, 0x41, 0x72, 0x63, 0x68, 0x69)'
十六进制(0x4e,0x49,0x42,0x41,0x72,0x63,0x68,0x69 .......)是我想要读取和稍后显示的数据
如何读取NSData?或者我可以如何将NSData转换为NSArray?
编辑: 问题解决