Last active
June 10, 2021 14:07
-
-
Save below/cb27c0d1ccdbdae3b27a73c0414afcd2 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
import CoreBluetooth | |
class Test: NSObject, CBPeripheralManagerDelegate { | |
func peripheralManager(_ peripheral: CBPeripheralManager, didAdd service: CBService, error: Error?) { | |
let peripheral: CBPeripheral | |
// So what I would like is something like this | |
// But this does not work :( | |
if #available(iOS 15, *) { | |
guard let nonOptional = service.peripheral else { | |
return | |
} | |
peripheral = nonOptional | |
} else { | |
peripheral = service.peripheral | |
} | |
let result: CBPeripheral = peripheral | |
print ("\(result)") | |
} | |
func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment