Last active
January 24, 2021 19:07
-
-
Save Kdan/912f29ea6e876b18d76b249c87d8ed97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Facade for the CBCentralManagerDelegate. | |
protocol CentralManagerDelegate: CBCentralManagerDelegate { | |
/// Function called when the central manager updates its state. | |
func centralManagerDidUpdateState(_ central: CentralManager) | |
/// Function called when the central manager discovers peripherals. | |
func centralManager(_ central: CentralManager, | |
didDiscover peripheral: Peripheral, | |
advertisementData: [String : Any], | |
rssi RSSI: NSNumber) | |
} | |
/// Wishful thinking... | |
/// This is unfortunately not possible due to the inherited objective-c exposure requirement from the CBCentralManagerDelegate file. | |
extension CentralManagerDelegate { | |
func centralManagerDidUpdateState(_ central: CBCentralManager) { | |
centralManagerDidUpdateState(central as CentralManager) | |
} | |
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { | |
centralManager(central as CentralManager, | |
didDiscover: peripheral as Peripheral, | |
advertisementData: advertisementData, | |
rssi: RSSI) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment