Posts

Post not yet marked as solved
0 Replies
277 Views
I'm implementing an app to connect to a bluetooth printer using CoreBluetooth. Here is some part of my code. var centralManager: CBCentralManager? var printerPeripheral: CBPeripheral? var printerCharacteristic: CBCharacteristic? public init() { centralManager = CBCentralManager(delegate: self, queue: nil) } public func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { if peripheral.name?.contains("printername") == true { printerPeripheral = peripheral centralManager?.connect(printerPeripheral!, options: nil) } } public func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) { printerPeripheral?.delegate = self printerPeripheral?.discoverServices(nil) } public func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) { for service in peripheral.services ?? [] { peripheral.discoverCharacteristics(nil, for: service) } } public func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) { } After the line printerPeripheral?.discoverServices(nil), I got the error. Unrecognized selector -[MyPrinterManager centralManager:didUpdateMTUForPeripheral:] It has not yet reached didDiscoverServices nor didDiscoverCharacteristicsFor service I can't find anything about didUpdateMTUForPeripheral anywhere. Anyone has any idea how I should fix this?
Posted
by mrhangz.
Last updated
.