I've hit a block with what I believe should be a reasonably straightforward use of CoreBluetooth within Swift 4:
func reConnect() {
print("attempt to retrieve ...")
let uuid = UUID(uuidString: "9A5B8540-F564-3829-845D-0FBF4BF2260E")!
let retrievedPeripherals = centralManager.retrievePeripherals(withIdentifiers: [uuid])
print("result is: \(retrievedPeripherals)")
}
I simply want to pass a known Device UUID to centralManager.retrievePeripherals(withIdentifiers) but crashing out with
Unexpectedly found nil while unwrapping an Optional value
I've hard-wired the Device UUID on line 03 - I know this UUID to be correct with the test iPhone and BLE device combination that I've got.
Any hewlp would be massively appreciated.