---
title: "peripheral(_:didDiscoverServices:)"
framework: corebluetooth
role: symbol
role_heading: Instance Method
path: "corebluetooth/cbperipheraldelegate/peripheral(_:diddiscoverservices:)"
---

# peripheral(_:didDiscoverServices:)

Tells the delegate that peripheral service discovery succeeded.

## Declaration

```swift
optional func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: (any Error)?)
```

## Parameters

- `peripheral`: The peripheral to which the services belong.
- `error`: The reason the call failed, or nil if no error occurred.

## Discussion

Discussion Core Bluetooth invokes this method when your app calls the discoverServices(_:) method. If the peripheral successfully discovers services, you can access them through the peripheral’s services property. If successful, the error parameter is nil. If unsuccessful, the error parameter returns the cause of the failure. For more information, see Core Bluetooth Programming Guide.

## See Also

### Discovering Services

- [peripheral(_:didDiscoverIncludedServicesFor:error:)](corebluetooth/cbperipheraldelegate/peripheral(_:diddiscoverincludedservicesfor:error:).md)
