CoreBluetooth has refactored both their CBCentralManager and CBPeripheralManager to inherit from CBManager.
In this new class, the CBManagerState enumeration exists. This is kind of a big change.
What is the best strategy for supporting both CBManagerState along side with CBCentralManagerState and CBPeripheralManagerState enums?
This code begins to look quite messy. I don't know of a way to check enum availability, so I check the class that this new property is used in instead.
- (void)centralManagerDidUpdateState:(CBCentralManager *)central {
if ([CBManager class]) {
self.updatedStateBlock((CBManagerState)central.state);
}
else {
self.updatedStateBlock((CBCentralManagerState)central.state);
}
}Previously my updatedStateBlock was defined as such, but now the named ns_enumeration has changed its name.
@property (nonatomic, copy) void (^updatedStateBlock)(CBCentralManagerState state);I could possibly refactor my framework API to pass the manager instead, and then the caller would have to query the state property, and do a class availability check as above.
I understand the desire to put all of the XPC connection stuff in a super class, but I feel this change is an API breaking one.
Anyone got any slick ideas? To unify the signature I could typecast as NSInteger, but then I lose the strongly typed value and the protection in code it has.