gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 01:08:36 25 4
gpt4 key购买 nike

我正在使用以下代码:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com