【发布时间】:2019-04-22 08:03:27
【问题描述】:
尝试在 Swift 4.2 项目中初始化 CBCentralManager。 获取注释中显示的错误:
import CoreBluetooth
class SomeClass: NSObject, CBCentralManagerDelegate {
// Type of expression is ambiguous without more context
let manager: CBCentralManager = CBCentralManager(delegate: self, queue: nil)
// MARK: - Functions: CBCentralManagerDelegate
func centralManagerDidUpdateState(_ central: CBCentralManager) { }
}
如果我将self 切换为nil,错误就会消失,所以我认为我在遵守CBCentralManagerDelegate 时遗漏了一些重要的东西...
我可以在没有委托的情况下使用管理器吗?如果没有,我需要怎么做才能解决错误?
【问题讨论】:
标签: ios swift core-bluetooth cbcentralmanager