-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for CoreBluetooth changes by iOS15 #10
base: master
Are you sure you want to change the base?
Conversation
Thanks! Let me do a quick check on this and I'll merge. |
@@ -275,7 +275,7 @@ extension Sensor: CBPeripheralDelegate { | |||
|
|||
/// :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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.