centralManager(_:didDisconnectPeripheral:error:)
Tells the delegate that the central manager disconnected from a peripheral.
Declaration
optional func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: (any Error)?)Parameters
- central:
The central manager that provides this information.
- peripheral:
The now-disconnected peripheral.
- error:
The cause of the failure, or
nilif no error occurred.
Discussion
The manager invokes this method when disconnecting a peripheral previously connected with the connect(_:options:) method. The error parameter contains the reason for the disconnection, unless the disconnect resulted from a call to cancelPeripheralConnection(_:). After this method executes, the peripheral device’s CBPeripheralDelegate object receives no further method calls.
All services, characteristics, and characteristic descriptors a peripheral become invalidated after it disconnects.