我正在使用以下代码:
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;
CBPeripheral
的identifier
属性是一个NSUUID
类对象,它有一个返回NSString
的方法UUID 的表示形式。
有关详细信息,请参阅类引用:https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSUUID_Class/
关于ios - 在 'uuid' 类型的对象上找不到属性 'CBPeripheral *',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36036633/