ios - 在 'uuid' 类型的对象上找不到属性 'CBPeripheral *'

标签 ios core-bluetooth uuid nsuuid

我正在使用以下代码:

CFStringRef cfstr = CFUUIDCreateString(NULL, self.peripheral.uuid);

这会返回一个错误

"Property 'uuid' not found on object of type 'CBPeripheral *'"

我认为这是因为 uuid 已被弃用,但我不确定如何更正它。

我尝试将 self.peripheral.uuid 更改为 self.peripheral.identifier 但这给了我

'incompatible pointer types passing retainable parameter of type 'NSUUID *' to CF Function expecting 'CFUUIDRef' (aka 'const struct __CFUUID *') type

如果可以,请帮忙。

最佳答案

如果您尝试将外设的UUID作为CFStringRef获取,那么您需要做的就是:

CFStringRef cfstr = (__bridge CFStringRef)peripheral.identifier.UUIDString;

CBPeripheralidentifier 属性是一个NSUUID 类对象,它有一个返回NSString 的方法UUID 的表示形式。

有关详细信息,请参阅类引用:https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSUUID_Class/

关于ios - 在 'uuid' 类型的对象上找不到属性 'CBPeripheral *',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36036633/

相关文章:

ios - 如何切换自定义应用内键盘

objective-c - 从 txt 文件中读取字符串到 iOS 中的 NSArrays

ios - 如何制作我自己的 UIPickerView?

iphone - 如何控制 UISlider Value Changed-events 频率?

node.js - 为什么我不能在 NodeJS 应用程序中使用字符串 uuid 作为自定义 MongoDB _id?

ios - 如何在表格单元格中自动更改标签的大小?

ios - 葡萄糖概况 - IOS

ios - 当 BLE 设备不再可见时处理

uuid - 为什么最好使用 UUID 来存储唯一的 id 值?

Python-基于UUID的分片