Guides and Sample Code


Playground Book Format Reference


The protocol you adopt to display an available peripheral in a playground page’s connection view.

The example below shows a conformance to this protocol that uses images from a playground book’s Public and Private Resources Folders.

  1. extension PageViewDelegate: PlaygroundBluetoothConnectionViewDataSource {
  2. func connectionView(_ connectionView: PlaygroundBluetoothConnectionView, itemForPeripheral peripheral: CBPeripheral, withAdvertisementData advertisementData: [String: Any]?) -> PlaygroundBluetoothConnectionView.Item {
  3. let icon = UIImage(named: "Peripheral_Icon_Normal")!
  4. let issueIcon = UIImage(named: "Peripheral_Icon_Issue")!
  5. let name = ?? peripheral.identifier.uuidString
  6. return .init(name: name, icon: icon, issueIcon: issueIcon)
  7. }
  8. }

Some peripherals have Bluetooth characteristics that provide information about the peripheral’s battery charge level or firmware status. Include this information in the PlaygroundBluetoothConnectionView.Item you create when it will help users pick a peripheral.

Instance Methods


Tells the delegate that a new peripheral was discovered and can be displayed in the connection view.



  • func connectionView(_ connectionView: PlaygroundBluetoothConnectionView,



The connection view showing available peripherals.


The peripheral to display in the connection view.


The advertisement data you use to help decide how to display the peripheral.

Return Value

A PlaygroundBluetoothConnectionView.Item instance which is displayed within a PlaygroundBluetoothConnectionView.