Create a new App project in Playgrounds 4 and paste the following code into a new swift file or inside the MyApp file:
import CoreBluetooth
class BTDelegate:NSObject, CBPeripheralDelegate{
public func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor descriptor: CBDescriptor, error: Error?){
}
public func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?){
}
}
This causes the following error to appear:
Method 'preview__peripheral(:didUpdateValueFor:error:)' withObjective-C selector '_preview__peripheral:didUpdateValueFor:error:' conflicts with previous declaration with the same Objective-C selector
Obviously some Playgrounds preview magic can't handle methods with the same name, but different type signature. Unfortunately I can't rename the methods because they are part of the CBPeripheralDelegate protocol.
Does anyone know a way to solve this problem?
I found the following workaround: If you separate the two conflicting methods into two different files as extensions on BTDelegate Playgrounds App compiles the code without an error. Unfortunately I could not yet test if in this case both delegate methods are still being called by CoreBluetooth.