如何从 CBCharacteristic 中获取精确值?
How to get exact value from a CBCharacteristic?
<CBCharacteristic: 0x156d48cf0, UUID = BLevel, properties = 0x18, value = <32353732 380d0a>, notifying = YES>
我想提取值字段中的内容。
NSData *data = c.value; // c is of type CBCharacteristic
但是不知道是哪一种值?
您可以使用
将 NSData
转换为 NSString
NSString *str = [[NSString alloc] initWithData:c.value encoding:NSUTF8StringEncoding];
<CBCharacteristic: 0x156d48cf0, UUID = BLevel, properties = 0x18, value = <32353732 380d0a>, notifying = YES>
我想提取值字段中的内容。
NSData *data = c.value; // c is of type CBCharacteristic
但是不知道是哪一种值?
您可以使用
将NSData
转换为 NSString
NSString *str = [[NSString alloc] initWithData:c.value encoding:NSUTF8StringEncoding];