Support for CoreBluetooth changes by iOS15#10
Support for CoreBluetooth changes by iOS15#10jooyyy wants to merge 2 commits intocodeinversion:masterfrom
Conversation
|
Thanks! Let me do a quick check on this and I'll merge. |
| /// :nodoc: | ||
| public func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) { | ||
| guard let service = services[characteristic.service.uuid.uuidString] else { return } | ||
| guard let service = services[characteristic.service?.uuid.uuidString ?? ""] else { return } |
There was a problem hiding this comment.
Just a thought but would it logically make more sense to use guard to check for the service/uuidString instead of defaulting to an empty string?
guard let uuidString = characteristic.service?.uuid.uuidString, let service = services[uuidString] else { return }
Functionally I think they're about the same but it seems weird you might try to access a service with the uuid of ""
There was a problem hiding this comment.
Did the service param change from an optional? you can't access a map value with an optional key, hence the ""
Edit: ... I think the service param here became an optional, so the "" is necessary.
... this might be weird...
There was a problem hiding this comment.
This function is a callback from CoreBluetooth. You're already indexing services by uuid. If for some reason CB sends you an update for a service without a UUID, you're basically screwed, so, I'd say ignore it.
guard let serviceUUID = characteristic.service?.uuid.uuidString else { return }
guard let service = services[serviceUUID] else { return }
No description provided.