'When will CBService.peripheral become nil inside delegate method peripheral didDiscoverServices
Inside CBPeripheralDelegate delegate method of peripheral didDiscoverServices, service.peripheral used to be non optional but as Swift update it became optional now.
In what situation it becomes nil and how was it handled before it became optional?
func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
if let services = peripheral.services {
for service in services {
switch service.uuid {
case BLEService.deviceInfo.uuid:
// service.peripehal < used to be non optional
service.peripheral?.discoverCharacteristics([
/* ... */
], for: service)
default:
break
}
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
