Skip to content
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

iOS 15 support #1

Merged
merged 6 commits into from
Jan 3, 2022
Merged

iOS 15 support #1

merged 6 commits into from
Jan 3, 2022

Conversation

chamira-at
Copy link

There are some changes to the Core Bluetooth API.

CBService
unowned(unsafe) var peripheral: CBPeripheral { get }

CBCharacteristic
unowned(unsafe) var service: CBService { get }

CBDescriptor
unowned(unsafe) var characteristic: CBCharacteristic { get }
iOS 15.X

CBService
weak var peripheral: CBPeripheral? { get }

CBCharacteristic
weak var service: CBService? { get }

CBDescriptor
weak var characteristic: CBCharacteristic? { get }

The changes are detailed describe here in this issue

Solution:

Made below classes' convenience init(…) methods optional convenience init?(…) and only initialize if pass in params required properties(service, characteristic, descriptors) are not deallocated.

RxBluetoothKit

- Characteristic.swift
- Descriptor.swift

Example

    convenience init?(descriptor: CBDescriptor, peripheral: Peripheral) {

        guard let _characteristic = descriptor.characteristic, let _service = _characteristic.service else {
            return nil
        }

        let service = Service(peripheral: peripheral, service: _service)
        let characteristic = Characteristic(characteristic: _characteristic, service: service)
        self.init(descriptor: descriptor, characteristic: characteristic)
    }

Caller sites have been always guard strogeRefeance therefore, added an extra guard for those that are optionally initializable.

Test

Test cases are update and force unwrapped for those optional initializable objects.

Other improvement

Fixed deprecated method signature warnings.

@chamira-at chamira-at changed the title Ios 15 support iOS 15 support Dec 17, 2021
@chamira-at chamira-at merged commit 3a50c3f into Airthings:master Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant